We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Create one top level bookmark

Hi,

I want to create one top level bookmark for each pdf file, then keep the same bookmark structure in the pdf under the newly created bookmark.

It would be appreciated if you share any code samples to insert a bookmark in hte top level.

Thanks

Selva

Hi Selva,


Thanks for your inquiry. I’m afraid I’m not clear about your requirements. It would be helpful if you please share some sample expected PDF document here. We will look into it and will provide you more information accordingly.

Sorry for the inconvenience faced.

Best Regards,

Dear Tilal Ahmad,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for your response.

I want to insert a new bookmark on top of existing bookmarks.

Please find attached the sample PDF document.

In the attached document, there are four bookmarks say "First bookmark", "Second bookmark", "Third bookmark" and "Fourth bookmark".

I want to insert new bookmark say "New bookmark" at first level on top of all the bookmarks.

I want the bookmark order to be as below

"New bookmark", "First bookmark", "Second bookmark", "Third bookmark" and "Fourth bookmark".

Please advice how to achieve this.

Regards

Selva

Hi Selva,


Please accept my apologies for delayed response.

Thanks for your feedback. I’ve logged your requirement in our issue tracking system as PDFNEWNET-35228 for further investigation and resolution. I’ll keep you updated regarding issue progress via this forum thread.

Thanks for your patience and cooperation.

Best Regards,

Hi Selva,


Thanks for your patience. Please check following code snippet hopefully it will help you to fulfill your requirements.

Document doc = new Document(myDir + “Magnification.pdf”);
OutlineCollection rootBookmark = doc.Outlines;
OutlineItemCollection newRootBookmark = new OutlineItemCollection(rootBookmark);
newRootBookmark.Title = “New bookmark”;
newRootBookmark.Destination = new FitHExplicitDestination(1, doc.Pages[1].Rect.Height);
// or newRootBookmark.Action = …
foreach (OutlineItemCollection bookmarks in rootBookmark)
{
newRootBookmark.Add(bookmarks);
}
doc.Outlines.Delete();
doc.Outlines.Add(newRootBookmark);
doc.Save(myDir + “Magnification_out.pdf”);

Please feel free to contact us for any further assistance.

Best Regards,

Hi Tilal Ahmad,

Thank you for the sample code.

But the existing bookmark level is changed. all the existing bookmark is added as a child of new bookmark.

The new bookmark should be on top of all the existing bookmark, the existing bookmark level should not be changed.

Please advice how to achieve this.

Thank you...

Regards

Selva

Hi Selva,


Sorry for the inconvenience faced. Can you please share your desired sample output here? So we look into it and provide you information accordingly.

Best Regards,

Hi,

Please find the attached sample PDF file. i have added "New bookmark" manually on top of it.

Thanks...

Regards

Selva

Hi Selva,


Thanks for providing additional information. We are looking into your requirement and will update you soon.

Thanks for your patience and cooperation.

Best Regards,

Hi Tilal Ahmad,

I would like to know the status of this ticket

Thank you...

Regards

Selvav

Hi Selva,


Thanks for your inquiry. I’m afraid the reported issue is still not resolved due to other priority tasks. However, I’ve request the team to share their findings as soon as possible. I’ll update you as soon as I get a feedback.

Thanks for your patience and cooperation.

Best Regards,

Hi Selva,


Thanks for your patience. Please check following code snippet for your requirements. Hopefully it will serve the purpose.

Document doc = new Document(myDir + “Magnification.Pdf”);
// Save previous bookmarks list.
IList prevBookmarks = new List();
foreach (OutlineItemCollection bookmark in doc.Outlines)
{
prevBookmarks.Add(bookmark);
}
// Create new top bookmark.
OutlineItemCollection newTopBookmark = new OutlineItemCollection(doc.Outlines);
newTopBookmark.Title = “New bookmark”;
newTopBookmark.Destination = new FitHExplicitDestination(doc.Pages[1], 792);
// or newTopBookmark.Action = new GoToAction(doc.Pages[1]);

doc.Outlines.Delete();
doc.Outlines.Add(newTopBookmark);
foreach (OutlineItemCollection prevBookmark in prevBookmarks)
{
doc.Outlines.Add(prevBookmark);
}
doc.Save(myDir + “Magnification_out.pdf”);

Please feel free to contact us for any further assistance.

Best Regards,

Hi,

its working good :)

Thank you very much for your solution

Hi Selva,


Thanks for your feedback. Its good to know you have achieved your desired results. Please let us know if you need any further assistance.

Best Regards,