Adding Bookmarks to merged document

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v9)  /  Adding Bookmarks to merged document

DynamicPDF CoreSuite for .NET (v9) Forum

 Jan 24 2018 6:44 PM
Hello,

i'm trying to add bookmarks to a merged document. I've searched the forum and tried several suggestions, but the merged PDF does not contain any bookmarks.
Maybe i'm missing something...

In my example i want to have bookmarks to the first pages of 1.pdf, 3.pdf and 4.pdf...

Here's the code i'm using:

Dim mdoc As Merger.MergeDocument = New Merger.MergeDocument()

        Dim pageList As New List(Of Integer)

        mdoc.Append("D:\Index.pdf")
        pageList.Add(mdoc.Pages.Count)

        mdoc.Append("D:\1.pdf")

        mdoc.Append("D:\2.pdf")
        pageList.Add(mdoc.Pages.Count)

        mdoc.Append("D:\3.pdf")
        pageList.Add(mdoc.Pages.Count)

        mdoc.Append("D:\4.pdf")

        For i As Integer = 0 To pageList.Count - 1
            mdoc.Pages(pageList(i)).Elements.Add(New Bookmark("Page " & pageList(i), 0, 0))
        Next

        mdoc.Draw("D:\output.pdf")
I did another test with the above code, just took out 3.pdf and 4.pdf as they already contain bookmarks.
It then worked with the code above.
If i include the PDFs with the bookmarks, i can't add bookmarks to the other pages at all and the bookmarks  from 3.pdf and 4.pdf are gone.
Posted by a ceTe Software moderator
Hello,

Please send over the following details to support@cete.com so we can look into the issue further.
1. Input PDFs.
2. Output PDF.
3. Exact version and build number of the DynamicPDF DLL file. You can get this information in DLL reference properties (Version and Description fields) in Visual Studio.

Thanks,
ceTe Software Support Team.
Posted by a ceTe Software moderator
Hello Maren,

Since you don’t need the existing bookmarks in documents 3 and 4 I suggest you avoid importing them as shown below using MergeOptions class. This should resolve the issue you are experiencing.

        Dim mdoc As Merger.MergeDocument = New Merger.MergeDocument()

        Dim pageList As New List(Of Integer)

        Dim options As MergeOptions = New MergeOptions()
        options.Outlines = False

        mdoc.Append("D:\Index.pdf")
        pageList.Add(mdoc.Pages.Count)

        mdoc.Append("D:\1.pdf")

        mdoc.Append("D:\2.pdf")
        pageList.Add(mdoc.Pages.Count)

        mdoc.Append("D:\3.pdf", options)
        pageList.Add(mdoc.Pages.Count)

        mdoc.Append("D:\4.pdf", options)

        For i As Integer = 0 To pageList.Count - 1
            mdoc.Pages(pageList(i)).Elements.Add(New Bookmark("Page " & pageList(i), 0, 0))
        Next

        mdoc.Draw("D:\output.pdf")

Thanks,
ceTe Software Support Team.
This worked for me, thank you very much :)
I hope you manage to find the problem so pdfs can be merged regardless of them having bookmarks or not.

All times are US Eastern Standard time. The time now is 3:47 PM.