Forums

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Merger for .NET (v7.x)  /  Bookmarks with Merged Documents

Forum Thread - Bookmarks with Merged Documents

 Feb 01 2018 10:20 AM
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.


 Feb 01 2018 3:41 PM
Posted by a ceTe Software moderator
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.
 Feb 01 2018 4:32 PM
So simple yet so elusive to me.

Many thanks. The help with this product rocks!
 Feb 02 2018 9:51 AM
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?
 Feb 02 2018 9:53 AM
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?
 Feb 02 2018 1:11 PM
Posted by a ceTe Software moderator
Hello,

Can you please send over the following details to 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.
 Feb 02 2018 2:06 PM
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.

All times are US Eastern Standard time. The time now is 7:19 AM.