Pdf Open Action default view

Dear Aspose,


I am having trouble specifying the default view for Pdf documents. I would like them all to open to fit the page width and open at the very start of the document i.e. top edge of first page.
This is the code I am using and while it zooms to the page width it does not start at the top of the document. Aspose.Pdf version 9.4.0.

Please help!

var pdfDocument = new Aspose.Pdf.Document(pdfDocumentStream);
pdfDocument.OpenAction = new GoToAction(new FitHExplicitDestination(pdfDocument.Pages[1], 0d));
pdfDocument.OptimizeResources(new Aspose.Pdf.Document.OptimizationOptions
{
LinkDuplcateStreams = true,
RemoveUnusedObjects = true,
RemoveUnusedStreams = true,
CompressImages = true,
ImageQuality = 90
});
pdfDocument.Optimize();
pdfDocument.Save();

James

Hi James,


Thanks for your inquiry. Please use following code snippet for your requirements. It will help you to accomplish the task.


pdfDocument.OpenAction = new
GoToAction(new
FitHExplicitDestination(pdfDocument.Pages[1],
pdfDocument.Pages[1].Rect.Height));


Please feel free to contact us for any further assistance.


Best Regards,

Hi Tilal,

That worked perfectly. You might want to consider updating the documentation as it’s not clear what that last double parameter should be.

http://www.aspose.com/docs/display/pdfnet/FitHExplicitDestination+Class

(i.e. it says “top” which is why I put 0 - I would argue it perhaps the opposite!)

Many thanks,

James

Hi James,


Thanks for your feedback. It is good to know your issue has been fixed.

Moreover, we are sorry for the confusion. Please note as described in documenation that Point is measuring unit of Aspose Pdf and 72 points=1 Inch. In case of A4 page size, coordinates of lower left corner are (0,0) and top right corner are (594,841). You were passing 0 as second parameter so it was actually referring to bottom of first page and apparently top of second page. Hopefully it will clear you the second parameter behavior.

Best Regards,