I have created a PDF document for viewing and i want to set some properties, like viewing size. But i do not know how can i set a default zoom level in the PDF file i created. So, my query is, can anybody please provide any solution for this problem?
This article on XsPDF.com is what are you looking for, check out: PDF Library for .NET.
Answers
To set zoom level, i think you can control it by specifying FitWindow(true). By setting this, in general, the zoom factor will be calculated based on the window size and PDF page size.
I find that PdfDocument has members PageLayout and PageMode. So, guess you may have a try with the following code.
PdfDocument outputDocument = new PdfDocument();
outputDocument.PageLayout = PdfPageLayout.SinglePage;
Hope this can help.
Thank you for replying. But the code is not working for me. Is there a new way of solving this?
The follows is my code that works on my side. It seems a solution for your case. At least, for u to refer.
PdfDictionary dict = new PdfDictionary(pdf); dict.Elements["/S"] = new PdfName("/GoTo"); PdfArray array = new PdfArray(pdf); dict.Elements["/D"] = array; PdfReference iref = PdfInternals.GetReference(pdf.Pages[0]); array.Elements.Add(iref); array.Elements.Add(new PdfName("/XYZ")); array.Elements.Add(new PdfInteger(-32768)); array.Elements.Add(new PdfInteger(-32768)); array.Elements.Add(new PdfInteger(1)); pdf.Internals.AddObject(dict); pdf.Internals.Catalog.Elements["/OpenAction"] = PdfInternals.GetReference(dict);
Thanks for replying. I will try it soon and report my results here.
It works for me now. Great Thx!