Some of my documents must have special page settings, like MarginLeft, MarginTop, etc.
But i can't find the way to save them.
How?
Waiting for answers
How can i save the PageSetup settings into my document?
-
- Site Admin
- Posts: 17602
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17602
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Yes. I found my old e-mail with explanations how to modify the ActionTest demo to save margins in RVF. It is quoted below.
1) Include rvfoSaveDocProperties and rvfoLoadDocProperties in
RichViewEdit1.RVFOptions
2) Write two procedures for saving and loading headers and footers (and RVPrint margins):
3) Now you need to update docproperties when page properties are changes.
In new version of RichViewActions, you can use rvActionPageSetup.OnChange event (simply call SaveDocProps there)
In older version of RichViewActions, use OnExecute:
First call default Execute (showing dialog), then save changes in
RichViewEdit1.DocProperties:
4) Process rvActionSave.OnDocumentFileChange
(this event is already processed in the ActionTest demo)
It also possible to save this information to RTF (using OnSaveRTFExtra), but not possible to read
Fixed: the line "s := Values['LeftMarginMM'];" is added
1) Include rvfoSaveDocProperties and rvfoLoadDocProperties in
RichViewEdit1.RVFOptions
2) Write two procedures for saving and loading headers and footers (and RVPrint margins):
Code: Select all
procedure TForm3.LoadDocProps;
var s: String;
begin
with RichViewEdit1.DocProperties do begin
RVA_HeaderInfo.Text := Values['HeaderText'];
RVA_FooterInfo.Text := Values['FooterText'];
RVA_HeaderInfo.Alignment := TAlignment(StrToIntDef(Values['HeaderAlign'],0));
RVA_FooterInfo.Alignment := TAlignment(StrToIntDef(Values['FooterAlign'],0));
RVA_HeaderInfo.PrintOnFirstPage := StrToIntDef(Values['HeaderFP'],1)<>0;
RVA_FooterInfo.PrintOnFirstPage := StrToIntDef(Values['FooterFP'],1)<>0;
s := Values['LeftMarginMM'];
RVPrint1.LeftMarginMM := StrToIntDef(s, 20);
s := Values['TopMarginMM'];
RVPrint1.TopMarginMM := StrToIntDef(s, 20);
s := Values['RightMarginMM'];
RVPrint1.RightMarginMM := StrToIntDef(s, 20);
s := Values['BottomMarginMM'];
RVPrint1.BottomMarginMM := StrToIntDef(s, 20);
end;
end;
procedure TForm3.SaveDocProps;
begin
with RichViewEdit1.DocProperties do begin
Clear;
Add('HeaderText='+RVA_HeaderInfo.Text);
Add('FooterText='+RVA_FooterInfo.Text);
Add('HeaderAlign='+IntToStr(Ord(RVA_HeaderInfo.Alignment)));
Add('FooterAlign='+IntToStr(Ord(RVA_FooterInfo.Alignment)));
Add('HeaderFP='+IntToStr(Ord(RVA_HeaderInfo.PrintOnFirstPage)));
Add('FooterFP='+IntToStr(Ord(RVA_FooterInfo.PrintOnFirstPage)));
Add('LeftMarginMM='+IntToStr(RVPrint1.LeftMarginMM));
Add('TopMarginMM='+IntToStr(RVPrint1.TopMarginMM));
Add('RightMarginMM='+IntToStr(RVPrint1.RightMarginMM));
Add('BottomMarginMM='+IntToStr(RVPrint1.BottomMarginMM));
end;
end;
In new version of RichViewActions, you can use rvActionPageSetup.OnChange event (simply call SaveDocProps there)
In older version of RichViewActions, use OnExecute:
First call default Execute (showing dialog), then save changes in
RichViewEdit1.DocProperties:
Code: Select all
procedure TForm3.rvActionPageSetupExecute(Sender: TObject);
begin
(Sender as TrvActionPageSetup).OnExecute := nil;
(Sender as TrvActionPageSetup).Execute;
(Sender as TrvActionPageSetup).OnExecute := rvActionPageSetupExecute;
RichViewEdit1.Change;
SaveDocProps
end;
(this event is already processed in the ActionTest demo)
Code: Select all
procedure TForm3.rvActionSave1DocumentFileChange(Sender: TObject;
Editor: TCustomRichViewEdit; const FileName: String;
FileFormat: TrvFileSaveFilter; IsNew: Boolean);
begin
....
LoadDocProps;
end;
Fixed: the line "s := Values['LeftMarginMM'];" is added
Last edited by Sergey Tkachenko on Wed Oct 19, 2005 12:37 pm, edited 1 time in total.