Lazarus

Programming => Packages and Libraries => RichMemo => Topic started by: Badger on March 17, 2023, 09:58:03 am

Title: Page Break in Rich Memo
Post by: Badger 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?
Title: Re: Page Break in Rich Memo
Post by: paweld 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.  
Title: Re: Page Break in Rich Memo
Post by: Badger on March 18, 2023, 05:24:36 am
Thanks - works perfectly.
Just for completeness, how would you remove the page break?
Title: Re: Page Break in Rich Memo
Post by: paweld 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.  
Title: Re: Page Break in Rich Memo
Post by: Nicole on March 18, 2023, 11:02:42 am
2 more code snippets go into my library...
TinyPortal © 2005-2018