FirstPageHeader and NormalHeaders

General TRichView support forum. Please post your questions here
Post Reply
dasSYSTeam
Posts: 7
Joined: Fri Oct 20, 2017 9:12 am

FirstPageHeader and NormalHeaders

Post by dasSYSTeam » Thu Aug 23, 2018 12:33 pm

Hi Community,

I'm using SRichviewEdit-component and tried to add content like text or pictures in the header at the first page and different content in header of other pages at runtime by doing this:

...

SRichView.PageProperty.HeaderVisible:=true;
SRichView.PageProperty.TitlePage:=true;

....

SRichView.CurrentPage:=1;
SRichView.StartEditing(srvrveHeader);
SRichView.RVHeader.Clear;
...insert elements ...
SRichView.RVHeader.Format;

It works fine.
Then I insert other content in the normal editor. The document contains at least two pages, sometimes more.

If I do this (for example in onclick of a button, the document has 2 or more pages):

SRichView.CurrentPage:=2;
SRichView.StartEditing(srvrveHeader);
SRichView.RVHeader.Clear;
...insert elements ...
SRichView.RVHeader.Format;

I dont get what I expect. After calling StartEditing currentpage returns automaticly to the value 1. The activeeditor is then the header of the first page.

Does anybody of you know this problem an how can I fix it?

Thank your for reading this

Bernd Graupe
dasSYSTeam GbR

dasSYSTeam
Posts: 7
Joined: Fri Oct 20, 2017 9:12 am

Re: FirstPageHeader and NormalHeaders

Post by dasSYSTeam » Thu Aug 23, 2018 1:22 pm

I found an additional aspect:

The code

SRichview.Currentpage:=2;
SRichView.StartEditing(srvrveHeader);

... insert elements ....

like shown in the main theme
works fine, if the header for normalpagehaeders is not empty, for example if I wrote some text by editing the header manually in the Editor.
May be it helps to find out, why it doesn't work.

regards

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

Re: FirstPageHeader and NormalHeaders

Post by Sergey Tkachenko » Fri Aug 24, 2018 9:58 pm

If you activated header editing (using StartEditing) and want to modify RVHeader content, you need to use only editing methods. Do not use Clear and Format, but use methods like SelectAll, DeleteSelection, InsertText, etc.

However, if you need to generate a new document and do not need this operation to be undone, there a simpler and more efficient method: creating headers in SRichView.SubDocuments.
See viewtopic.php?f=3&t=8843

dasSYSTeam
Posts: 7
Joined: Fri Oct 20, 2017 9:12 am

Re: FirstPageHeader and NormalHeaders

Post by dasSYSTeam » Fri Aug 31, 2018 7:39 am

Hello Sergey,

first thank you for the demo to generate documents. It helps and works, but I have still a Problem.

I took the demo and made the following changes. I deleted the SRichViewEdit1 - component from the form and builded the Editor at runtime like this

.... TForm7
public
{ Public declarations }
SRichViewEdit1 : TSRichViewEdit;
procedure GenerateHeader(RVData: TCustomRVData; IncludeCompanyData: Boolean);
procedure GenerateFooter(RVData: TCustomRVData);
procedure GenerateMain(RVData: TCustomRVData);
procedure InsertMain(RichViewEdit: TCustomRichViewEdit);
procedure GenerateDoc;

end;

procedure TForm7.FormCreate(Sender: TObject);
begin
SRichViewEdit1:=TSRichViewEdit.Create(Self);
SRichViewEdit1.Align:=alClient;
SRichViewEdit1.Parent:=TWinControl(Self);
GenerateDoc;
end;

If you run this and scroll to the second page of the document, the normalheader is not correct shown and editing the document leeds to effects, where the height of the headers (the same with the footers) is counted incorrect. For example if you try to add text at the end of the first page.
If you click into the second page, the normal hader is shown correct, but the Header at the first page is cut.

Unfortunately i made a object, wich contains SRichViewEditor and Buttons and others and many functions to work with documents. This object is not a visual component and I have to create it at runtime and it creates the SRichViewEditor too. Everything worked fine, but now I have to solve this Problem. Can you please help me?

Thank you

Bernd Graupe
dasSYSTeam GbR
MakeSRVDocRunTime.zip
(9.88 KiB) Downloaded 8 times

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

Re: FirstPageHeader and NormalHeaders

Post by Sergey Tkachenko » Sun Sep 09, 2018 11:35 am

Call Loaded:

Code: Select all

 SRichViewEdit1:=TSRichViewEdit.Create(Self);
 SRichViewEdit1.Align:=alClient;
 SRichViewEdit1.Parent:=TWinControl(Self);
 SRichViewEdit1.Loaded;
 GenerateDoc;

Post Reply