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

Free Support Forum - aspose.com

Retaining bookmarks in pre-existing pdf file

Hi there,

Was wondering if someone could could advise on this issue we are experiencing?

We created a pdf document using the aspose library. Once created we have to attach a pre-existing pdf from our sharepoint library which we are able to do but it seems like it does not retain the bookmarks on the pre-existing pdf.

Would someone be able to explain why the bookmarks aren’t being retained when the pre-existing pdf is added to the newly created pdf?

Code for attaching the pre-existing pdf from SharePoint:

            //Add Meeting Papers that has been attached 
            for (int i = 0; i < documentLinks.Count(); i++)
            {
                byte[] fileContent = await _documentService.GetDocumentsViaDownload(accessToken, documentLinks[i]);
                MemoryStream fileStream1 = new MemoryStream(fileContent);
                Document docAttached = new Document(fileStream1);
                document.Pages.Add(docAttached.Pages);

            }

@cbparl

Please try to use the code snippet below in order to preserve the Bookmarks:

Facades.PdfFileEditor pfe = new Facades.PdfFileEditor();
pfe.CopyLogicalStructure = true;
pfe.CopyOutlines = true;
//pfe.KeepActions = true;
pfe.Concatenate(dataDir + "1.pdf", dataDir + "2.pdf", dataDir + "result.pdf");

Feel free to let us know in case you still face any issue.