Moved from "[Demos] Headers and Footers"

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
ivanRar
Posts: 3
Joined: Fri Aug 16, 2019 3:01 pm

Moved from "[Demos] Headers and Footers"

Post by ivanRar »

I am struggling a bit with the new headers and footers and maybe you can point me in the right direction.

First issue and to keep it simple. I have two pages. I want to take the header and footer from the first page and put them on the second page. Programmatically, how would I do this?

Second issue. Is there any way to safely read/write the contents of the SubDocument items? That is to say, take the data out, update it I use dynamic insertion of values in my headers/footers, and store the results back into the original location? The LoadRVFFromStream looks intimidating.

Thanks
Sergey Tkachenko
Site Admin
Posts: 17554
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Moved from "[Demos] Headers and Footers"

Post by Sergey Tkachenko »

1) As I understand, you want to copy the first page header to normal header.
It can be done via RVF memory stream:

Code: Select all

var
  Stream: TMemoryStream;

Stream := TMemoryStream.Create;
srve.SubDocuments[srvhftFirstPageHeader].SaveRVFToStream(Stream, False);
Stream.Position := 0;
srve.SubDocuments[srvhftNormalHeader].LoadRVFFromStream(Stream);
Stream.Free;
srve.Format;
This code works correctly if the header is not being edited. Otherwise, the current header is stored in srve.RVHeader, not in srve.SubDocuments.
So you can call this code in two cases:
- when srve is unformatted (for example, immediately after loading or generating document);
- when srve.RichViewEdit is being edited (to make sure, you can call srve.StartEditing(srvrveMain);
Sergey Tkachenko
Site Admin
Posts: 17554
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Moved from "[Demos] Headers and Footers"

Post by Sergey Tkachenko »

2) You can find the answer in my previous reply: you can safely modify SubDocuments except for cases when headers/footers are being edited. If they are being edited, a content of the certain SubDocuments[] will be overridden by a RVHeader/RVFooter content when the editing finishes.

You can also modify content of srve.RVHeader/RVFooter, but usually it makes sense to do it using editing methods (which can be undoable by users).
Post Reply