Free Support Forum - aspose.com

Inherit Zoom for Bookmarks using Aspose.PDF for .NET

Hi,
I need to know how can we modify the inherit zoom for existing PDF bookmarks. I will take the reference from .NET code but not get solution for existing bookmarks. Please let me know how to resolve this issue.
Thanks
Saurav Saxena

@sauravjava,

Thanks for contacting support.

I have observed your comments. Can you please share source file along with sample code so that we may further investigate to assist you in this regard.

sample.pdf (7.0 KB)
Thank you for support.
Please find the attachment.
I am trying to get XYZExplicitDestination and set zoom to “0”. But got an exception “Exception in thread “main” java.lang.ClassCastException: com.aspose.pdf.FitHExplicitDestination cannot be cast to com.aspose.pdf.XYZExplicitDestination”. Please review and let me know.

Thanks & Regards
Saurav Saxena

@sauravjava,

We have worked with source file shared by you and unable to observe the issue. Can you please share source code along with version details which you are using on your end.

Hi
PFB, the sample code:
Document document=new Document(“C:\Users\saurav.saxena\Documents\ECTD\sample.pdf”);
for(OutlineItemCollection itemCollection:document.getOutlines())
{
GoToAction action=(GoToAction) itemCollection.getAction();
XYZExplicitDestination destination = (XYZExplicitDestination) action.getDestination();
//need to set zoom value 0
}
How to set zoom level 0 or inherit for existing bookmarks? Currently got an exception “Exception in thread “main” java.lang.ClassCastException: com.aspose.pdf.FitHExplicitDestination cannot be cast to com.aspose.pdf.FitExplicitDestination”. Please check and let me know.
Thanks and Regards
Saurav Saxena

@sauravjava,

Can you please try to use following sample code on your end and share feedback with us if there is still an issue.

Document document=new Document(dataDir + “samplezoom1.pdf”);
for(OutlineItemCollection itemCollection:document.getOutlines())
{
GoToAction action=(GoToAction) itemCollection.getAction();
//need to set zoom value 0
Page page = ((FitHExplicitDestination)action.getDestination()).getPage();
action.setDestination(new XYZExplicitDestination(page, 0,page.getPageInfo().getHeight(),0));
}
document.save(dataDir + “output20.1.pdf”);

@Adnan.Ahmad
Thanks, I have got the solution.

@sauravjava,

You are very welcome.