You are not logged in.
Pages: 1
I am trying to set the ViewerPreference to "fitWindow". Here's what I do (I also tried the very latest version from github):
FPdfDoc.NewDoc;
FPdfDoc.Root.ViewerPreference := [vpFitWindow];
FPdfDoc.ScreenLogPixels := dpi;
FPdfDoc.DefaultPaperSize := psA4;
FPdfDoc.DefaultPageLandscape := false;
for i := 1 to rvh.PagesCount do // RichView renders the pages
begin
FPdfDoc.AddPage;
rvh.DrawPageAt(ALeft, ATop, i, FPdfDoc.VCLCanvas, false, DocHeight);
end;
FPdfDoc.SaveToFile(outname);
The expected PDF-items are added to the file, but after the pages. So neither Acrobat Reader nor PDFXChange View notices, that the setting is in that file.
How do I force SynPDF to put this information in front of the pages? Or is there something different that I am missing?
Thanks
Stefan
Offline
Why not put the ViewerPreference, ScreenLogPixels and DefaultPaper and Page size before you do FPdfDoc.NewDoc ?
(B.T.W. I use PDF.Root.PageLayout := plSinglePage; for opening the PDF as whole page. Not sure if that's what you want with fitWindow.)
Offline
....because it does not work. If done that way, it is not even at the end of the document.
I included the NewDoc only recently just to try, the TPDFdocumentGDI instance is created right before that.
And I found that snippet over at https://synopse.info/forum/viewtopic.php?id=781 where it is done that way. But either nobody checked, if that works or it once did.
The FitWindow preference should tell a viewer to open the document fit to the viewport width.
Thanks anyway
Stefan
Offline
And what did you mean by "The expected PDF-items are added to the file, but after the pages."?
If I use vpHideToolbar and vpHideMenubar in ViewerPreference they seem to work fine.
Even setting Landscape to true works.
Even for vpFitWindow it seems to be set at the top of the pdf.
%PDF-1.3
1 0 obj
<</Type/Catalog/PageLayout/SinglePage/Pages 3 0 R/ViewerPreferences<</FitWindow true>>>>
It's only because my pagelayout is set at SinglePage I don't think FitWindow is actually used/works.
The SinglePage is standard set as default. (FRoot.PageLayout := plSinglePage in TPdfDocument.NewDoc).
If you force it to plOneColumn you might get the result you want?
PDF.Root.PageLayout := plOneColumn;
PDF.Root.ViewerPreference := [vpFitWindow];
I'm not sure why for you the PageLayout and ViewerPreferences would be at the end of the pdf (if it is there).
Last edited by rvk (2022-07-22 22:19:27)
Offline
Pages: 1