Unable to set width for a PDF documents in MigraDoc library

38 views Asked by At

i am encounter a problem with the zoom level of the PDF.when i open the document By default,it showing with a zoom level of 25% because of page width(185). This can make the document look too small on the screen. what i given is -
Document document = new Document(); Section section = document.AddSection(); section.PageSetup.PageWidth = Unit.FromCentimeter(185); what i need is- when i open pdf document it should take the browser zoom level

1

There are 1 answers

1
I liked the old Stack Overflow On

The PdfDocument class has members like ViewerPreferences, PageLayout, and PageMode that allow to specify how a page should be displayed when opened in a PDF viewer. Not all PDF viewers may support open actions.

Note that the sample code in the question shows the MigraDoc Document, not the PDFsharp PdfDocument object which will later be generated by the PDF renderer.

Additionally, PDF files can contain "open actions" that execute when a file is opened. Not all PDF viewers may support open actions.

Here is a sample that shows how to set a PDF to fit vertically:
https://pdfsharp.net/wiki/WorkOnPdfObjects-sample.ashx
(Note: This links to the official PDFsharp site.)