How do I set zoom level when adding bookmarks to a pdf document?

When adding a bookmark to a PDF document, we use the code below



Dim bmaudit As Aspose.Pdf.Facades.Bookmark = New Aspose.Pdf.Facades.Bookmark()

bmaudit.Action = “GoTo”

bmaudit.Title = “Audit”

bmaudit.PageNumber = liauditpage

loEditor.CreateBookmarks(bmaudit)





When checking the properties of the added bookmarks, it shows us that the zoom level defined on the bookmark is ‘Fit page’ (see first attached file) and what we need as zoom level is ‘Inherit zoom’ (see second attached file)

How can we accomplish that?



Thanks in advance for any feedback,

Kay

Hi Kay,

Thanks for your inquiry. Please check the following code snippet to set the inherit zoom of a bookmark. Hopefully, it will help you to accomplish the task.

Dim doc As New Document(myDir + "Input.pdf")
Dim page1 As Page = doc.Pages(1)
Dim bookmark As New OutlineItemCollection(doc.Outlines)

bookmark.Action = New Aspose.Pdf.InteractiveFeatures.GoToAction(doc.Pages(1))
' Set inherit zoom
bookmark.Destination = New XYZExplicitDestination(page1, 0, page1.Rect.Height, 0)
bookmark.Title = "bookmark for page 1"

doc.Outlines.Add(bookmark)
doc.Save(myDir + "bookmark.pdf")

Please feel free to contact us for any further assistance.

Best Regards,