Search code examples
c#pdfitextadobe-reader

iTextSharp - Setting zoom to "Fit page" and maintain it


I can't manage to get the correct zoom on my document created with iTextSharp.

When opening the document, the zoom is fine, but as soon as I click on a Bookmark the zoom changes to the Setting of Adobe Reader.

So, for example:
- I open the pdf Document: Zoom is set to "Fit Page" (88% at my Resolution)
- I click on a Bookmark: Zoom changes to "Fit Width" (145% at my Resolution)

I've been searching for quite some time now. But I Need your help. This is what I use to Show the outlines + single page when opening.

        writer.ViewerPreferences = PdfWriter.PageModeUseOutlines | PdfWriter.PageLayoutSinglePage;

Adobe Reader Zoom Level

And this is the code used to produce the outlines:

outline = new PdfOutline(root, new PdfDestination(PdfDestination.FIT, writer.GetVerticalPosition(false)), someTitle, true);

Even if I Change the Zoom Setting manually to "Fit height" or "Fit page" it changes when I click on a Bookmark.

So the question is: How to Keep the Zoom Level at : "Fit Page", when I click on a Bookmark.

Thanks a lot for your help!


Solution

  • Alright. I thought this wouldn't matter but this works:

    outline = new PdfOutline(root, new PdfDestination(PdfDestination.FIT), someTitle,true);
    

    So, I just deleted the "writer.GetVerticalPosition(false)"