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
New Headers and Footers
-
- Site Admin
- Posts: 17524
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
I assume that you do not want to implement these operations as editing (undoable operations). If you want editing operations, you must not work with Subdocuments; you would need activating editing the header for the proper page, and make editing operations in it.
----
If a header/footer is being edited, the actual content of this header/footer is in SRV.RVHeader and SRV.RVFooter.
So, if you want working with Subdocuments, for simplicity, you should make sure that header/footer is not being edited.
It may be when TSRichViewEdit is not formatted yet (for example, just after loading from a file). If TSRichViewEdit is being edited, you can call SRV.StartEditing(srvrveMain).
Yes, you using SaveRVFToStream
Copying from the second page to all pages:
As for changing (not undoable), you can make changes directly in Subdocuments (assuming that it is not being edited, see above), such as
SRV.SubDocuments[srvhftNormalHeader].AddNL('Hello!', 0, 0);
then call
SRV.Format.
----
If a header/footer is being edited, the actual content of this header/footer is in SRV.RVHeader and SRV.RVFooter.
So, if you want working with Subdocuments, for simplicity, you should make sure that header/footer is not being edited.
It may be when TSRichViewEdit is not formatted yet (for example, just after loading from a file). If TSRichViewEdit is being edited, you can call SRV.StartEditing(srvrveMain).
Yes, you using SaveRVFToStream
Copying from the second page to all pages:
Code: Select all
var Stream: TMemoryStream;
Color: TColor;
Stream := TMemoryStream.Create;
SRV.SubDocuments[srvhftFirstPageHeader].SaveRVFToStream(Stream, False, clNone, nil, nil);
Stream.Position := 0;
Color := clNone;
SRV.SubDocuments[srvhftNormalHeader].LoadRVFFromStream(Stream, Color, nil, nil, nil, nil);
SRV.Format;
Stream.Free
SRV.SubDocuments[srvhftNormalHeader].AddNL('Hello!', 0, 0);
then call
SRV.Format.