Reputation: 36
I am using PDFSharp to add a bookmark to page one of a PDF document for a client. The client is providing multiple PDF documents with varying pages and each PDF is a single bill for a person. The client asked me to put the account number in a bookmark on the first page so they can combine them together and process a single PDF with many bills using the bookmark as a means to identify the account number.
I successfully created the bookmark using the following code, but when the client combines the files together using Ghostscript, all bookmarks are assigned to page 1 on the combined PDF. When they combine other PDF's from another system that essentially does the same thing the bookmarks display as desired on the combined file. I am not sure what they are doing differently to make this work.
How can I get the bookmark to be set correctly so it is maintained when combined?
string file = "c:/test.pdf";
string accountNumber = "001234";
using (PdfDocument doc = PdfReader.Open(file, PdfDocumentOpenMode.Modify))
{
PdfPage page = doc.Pages[0];
doc.Outlines.Add(accountNumber, page);
doc.Save(file);
}
Upvotes: 0
Views: 1489
Reputation: 36
I figured it out. Although redundant since the second parameter in Outlines.Add() is setting the destination page, I just needed the following line:
outline.DestinationPage = page;
Upvotes: 0