Page 1 of 1

How do I save/load a page format

Posted: Wed Mar 21, 2012 3:05 pm
by vit
How do I save/load a page format (orientation, margins, size etc)?

I store document in the way:

Code: Select all

procedure TDocEditFrame.SaveFile(const FileName: string);
var
  fs: TFileStream;
begin
  fs := TFileStream.Create(FileName, fmCreate or fmOpenWrite);
  try
    SRVE.RVHeader.SaveRVFToStream(fs, False);
    SRVE.RVFooter.SaveRVFToStream(fs, False);
    SRVE.RichViewEdit.SaveRVFToStream(fs, False);
  finally
    fs.Free;
  end;
end;
And load:

Code: Select all

procedure TDocEditFrame.LoadFile(const FileName: string);
var
  fs: TFileStream;
begin
  fs := TFileStream.Create(FileName, fmOpenRead);
  try
    SRVE.RVHeader.Clear;
    SRVE.RVFooter.Clear;
    SRVE.RichViewEdit.Clear;
    SRVE.RVHeader.LoadRVFFromStream(fs);
    SRVE.RVFooter.LoadRVFFromStream(fs);
    SRVE.RichViewEdit.LoadRVFFromStream(fs);
    SRVE.RVHeader.Format;
    SRVE.RVFooter.Format;
    SRVE.RichViewEdit.Format;
    SRVE.SetRVMargins;
  finally
    fs.Free;
  end;
end;
But the page format doesn't appear.


I'm aware I need to handle TRVAControlPanel.OnMarginsChanged and call SRVE.SetRVMargins from inside. But this event doesn't fire.

So what should I do to save/load the page format?

Posted: Wed Mar 21, 2012 4:50 pm
by Sergey Tkachenko
Saving:

Code: Select all

SRVE.RichViewEdit.SaveRVF(FileName, False); 
(you can use TFileStream and SaveRVFToStream, but it is not necesary).

Loading:

Code: Select all

SRVE.Clear;
SRVE.RichViewEdit.LoadRVF(FileName);
SRVE.Format;
Important: use Clear and Format methods of SRVE itself.

Note: TRVAControlPanel.OnMarginsChanged must be used only if loading is made using TrvActionOpen.