TRVPrintPreview lost pagesetup options of the rvf file

General TRichView support forum. Please post your questions here
Post Reply
wolf1860
Posts: 118
Joined: Sat Nov 21, 2015 2:04 am

TRVPrintPreview lost pagesetup options of the rvf file

Post by wolf1860 »

I need export rvf file to PDF. In the demo : RVSynPDFDemo, when I open the rvf file in TRVPrintPreview, the content layout is different from the display in SRichViewEdit. My export need high-precision,what should I do? I have emailed u my test rvf file.
Display in srichviewEdit:
Image
Display in TRVPrintPreview
Image
wolf1860
Posts: 118
Joined: Sat Nov 21, 2015 2:04 am

Re: TRVPrintPreview lost pagesetup options of the rvf file

Post by wolf1860 »

It looks like a bug.After load rvf file,I changed the TRVPrint.Margins by code and tested:
1) when LeftMarginMM:=0 and RightMarginMM:=0 ,the content preview looks as same as the rvf's real display,maybe TRVprint calculate them twice.The header and footer changed leftmargin/rightmarin to 0,they always response right.
2)when TopMarginMM:=0 and BottomMarginMM:=0 , the header and footer response right, the main content display wrong distance to the header and footer.
Sergey Tkachenko
Site Admin
Posts: 17554
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: TRVPrintPreview lost pagesetup options of the rvf file

Post by Sergey Tkachenko »

1) Output of TRVPrint and TSRichViewEdit can be different even with identical margins, because they format text at different pixel density (DPI).
TRVPrint uses the printer DPI, to create output as good as possible.
TSRichViewEdit uses the predefined high DPI value (hard-coded, independent of printers), to provide the same output on all printers and the screen.
Also, the pagination procedures are different (TSRichViewEdit does not support page breaks in table cells).

2) About margins. They calculated differently in TRVPrint and TSRichViewEdit.

2.a) In TRVPrint, there are two kinds of margins:
- page margins defined in TRVPrint properties (outer margins)
- document margins (the same margins as you can see in TRichViewEdit, LeftMargin, TopMargin, etc. properties) (inner margins)
See the first picture here: https://www.trichview.com/help/idh_class_trvprint.html
In RVF:
- inner margins are stored if rvfoSaveLayout and rvfoLoadLayout are included in RichViewEdit.RVFOptions
- outer margins are not stored; however, you can store identical properties of RichViewEdit.DocParameters (rvfoSaveDocProperties and rvfoLoadDocProperties in RVFOptions); after loading, you can apply them to TRVPrint using RichViewEdit.AssignToRVPrint method.

2.b) In TSRichViewEdit, the primary method of defining margins is TSRichViewEdit.PageProperty. However, an internal procedure synchronizes all other margins (in SRichViewEdit.RichViewEdit.DocParameters, SRichViewEdit.RichViewEdit.LeftMargin, SRichViewEdit.RichViewEdit.TopMargin, etc.), so they are set to the same values (but probably in different measure units).

And here comes the incompatibility: if you load RVF saved in TSRichViewEdit in TRichViewEdit, margins will be too large. It's because the values of RichViewEdit.LeftMargins, etc. (internal margins) are usually small, but in TSRichViewEdit they are equal to page margins. If TRVPrint applies is own margins, page margins are applied twice.
Unfortunately, it's hard to fix this incompatibility without adding new incompatibilities.

So:
- if possible, do not use TRichViewEdit to print documents created in TSRichViewEdit; use TSRichViewEdit, maybe with TSRVPrint and TSRVPrintPreview
- or you can set, after loading RVF, all TRichViewEdit's margins (LeftMargin, etc) = 0, and assign TRVPrint margins using AssignToRVPrint.
wolf1860
Posts: 118
Joined: Sat Nov 21, 2015 2:04 am

Re: TRVPrintPreview lost pagesetup options of the rvf file

Post by wolf1860 »

Thanks a lot first!
As I said,I want to export the content of TSrichViewEdit to PDF and I want the pdf's layout as same as the rvf looks in TSRichViewEdit.what should I do?Can u give me some demo code?
By the way ,I changed the margin properties after load rvf that saved from TSRichViewEdit in the demo app,the left/rightMargins worked,but the FooterY/TopMarginMM did not work.How to change the distance between the main content and the header/footer? I can not understand why the header and Footer response right but the main content margin left/right twice?
Sergey Tkachenko
Site Admin
Posts: 17554
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: TRVPrintPreview lost pagesetup options of the rvf file

Post by Sergey Tkachenko »

You need to use some third-party library for PDF generation.
Such as: eDocEngine, LLPDFLib, Synopse PDF, or other library that provides TCanvas where you can draw for converting to PDF.

eDocEngine includes an example for ScaleRichView.
For other libraries, just use SRichViewEdit.DrawPage to draw pages to their canvases.
Some additional code is needed if you want to export hyperlinks.

Do you know which PDF library you want to use?
wolf1860
Posts: 118
Joined: Sat Nov 21, 2015 2:04 am

Re: TRVPrintPreview lost pagesetup options of the rvf file

Post by wolf1860 »

Thank u! I'll try it:)
Post Reply