Bookmarks with Merged Documents

Bookmarks with Merged Documents

Forum member · Feb 1, 2018
I am having difficulty figuring out how to add an additional bookmark to a final merged PDF. I dynamically create a PDF based on user selection var pdfBytes = _document.Draw(); var createdPdf = new PdfDocument(pdfBytes); Next based on the selection I determine which file and path I need to place at the beginning of the document. var whatsnewFileAndPath = "\\server\share\file.pdf"; var finalPdf = new MergeDocument(); If the file exists then I append it to the new MergeDocument. This file has been created by the documentation team with bookmarks. if (File.Exists(whatsnewPath)) { finalPdf.Append(whatsnewFileAndPath); } Lastly I append the dynamically created PDF to the MergeDocument. If the file did exist then I need to create an additional bookmark pointing to the page where this PDF starts. So if my whatsnew doc is 10 pages then I need to add a bookmark for "createdPdf" on page 11. This is where I am having difficulties. finalPdf.Append(createdPdf); Thanks for any help.

Re: Bookmarks with Merged Documents

Support · Feb 1, 2018
Hello, You could use the page count of the finalPdf object to determine the page number of the next pdf that is going to be appended and add a bookmark at that page number. Your code would look something like this: //count the total pages in finalPdf up to that point. int count = finalPdf.Pages.Count; //append a new pdf. finalPdf.Append(createdPdf); //use the page count to add a bookmark after createdPdf is appended. finalPdf.Pages[count].Elements.Add(new Bookmark("createdPdf Bookmark", count, 0)); Let me know if you have any questions.

Re: Bookmarks with Merged Documents

Forum member · Feb 1, 2018
So simple yet so elusive to me. Many thanks. The help with this product rocks!

Re: Bookmarks with Merged Documents

Forum member · Feb 2, 2018
Well, I am still having an issue with this. Some of the document bookmarks work after the merge but not all. For this scenario I have two document with existing bookmarks, Doc A after the merger both the previous bookmarks and the newly added one works. On Doc B my newly created one works but the previous bookmarks do not. So far everyone that I have found to not work the previous bookmark were expandable. I am not sure of the correct terminology here but they have a plus sign next to them to expand then out like a tree view. They expand but clicking does not take you to the page. Should I be adding my bookmark a different way so these work?

Re: Bookmarks with Merged Documents

Forum member · Feb 2, 2018
Quick update. I removed the code to add my bookmark and found that the existing bookmarks still do not work. The bookmarks work before the documents are merged but not afterwards. Any ideas here?

Re: Bookmarks with Merged Documents

Support · Feb 2, 2018
Hello, Can you please send over the following details to [^a|mailto:support@cete.com|opennewwindow|support@cete.com^] so we can look into it further? 1. Code sample or a console application which uses static data to recreate the behaviour. 2. Input and output PDFs. 3. Exact version and build number of the DynamicPDF product DLL file used in the application. You can get this information in DLL references properties (Version and Description fields) in Visual Studio. 4. Additional details on the issue if any. Thanks, ceTe Software Support Team.

Re: Bookmarks with Merged Documents

Forum member · Feb 2, 2018
I already had one open for another issue I was having related to this. You can check it for my response. Support Incident Number is: S11575025 Thanks.