Recent

Author Topic: Page Break in Rich Memo  (Read 1823 times)

Badger

  • Full Member
  • ***
  • Posts: 144
Page Break in Rich Memo
« on: March 17, 2023, 09:58:03 am »
Is there any way to insert a page break in rich memo so that when the Rich memo contents are pasted to the clipboard and then the clipboard pasted into a word processor such as LibreOffice, the page break shows up on the word processor?
Badger
(A bad tempered, grumpy animal that sleeps most of the winter!)

If at first you don't succeed - you're running about average!

I'm using Windows 10 Lazarus v2.4.4  FPC 3.2.2   Win 32/64

paweld

  • Hero Member
  • *****
  • Posts: 1003
Re: Page Break in Rich Memo
« Reply #1 on: March 17, 2023, 02:06:01 pm »
chr(12), eg.
Code: Pascal  [Select][+][-]
  1. procedure TForm1.AddPageBreakClick(Sender: TObject);
  2. begin
  3.   RichMemo1.Lines.Insert(RichMemo1.Lines.Count div 2, #12);  //add a pagebreak in the middle of text
  4.   RichMemo1.CopyToClipboard;  
  5. end;  
  6.  
Best regards / Pozdrawiam
paweld

Badger

  • Full Member
  • ***
  • Posts: 144
Re: Page Break in Rich Memo
« Reply #2 on: March 18, 2023, 05:24:36 am »
Thanks - works perfectly.
Just for completeness, how would you remove the page break?
Badger
(A bad tempered, grumpy animal that sleeps most of the winter!)

If at first you don't succeed - you're running about average!

I'm using Windows 10 Lazarus v2.4.4  FPC 3.2.2   Win 32/64

paweld

  • Hero Member
  • *****
  • Posts: 1003
Re: Page Break in Rich Memo
« Reply #3 on: March 18, 2023, 08:49:00 am »
Code: Pascal  [Select][+][-]
  1. RichMemo1.Lines.Text := StringReplace(RichMemo1.Lines.Text, #12, LineEnding, [rfReplaceAll]);  //remove all pagebreaks
  2.  
Best regards / Pozdrawiam
paweld

Nicole

  • Hero Member
  • *****
  • Posts: 972
Re: Page Break in Rich Memo
« Reply #4 on: March 18, 2023, 11:02:42 am »
2 more code snippets go into my library...

 

TinyPortal © 2005-2018