I try to get the bookmarks and there corrospondig page number by using the "pdf.Outlines[i].TargetPageNumber". in the folloving code:
PdfDocument pdf = new PdfDocument(@"c:/test.pdf");
MergeDocument doc = new MergeDocument(pdf);
String name = pdf.GetText();
for (int i = 0; i < pdf.Outlines.Count; i++)
{
Console.WriteLine("headline " + i + " " + pdf.Outlines[i].Text +" "+ pdf.Outlines[i].TargetPageNumber);
}
I get the right bookmarks names but only get -1 as page number for all found bookmarks.
By looking at the documentation I found the following statement - "The target page number is only known for imported outline actions that use a direct reference to a page." (https://www.dynamicpdf.com/Support/NET_Help_Library_16_02/ceTe.DynamicPDF~ceTe.DynamicPDF.Merger.PdfOutline~TargetPageNumber.html).
Can you the me understand what it means and how to fix the problem ?
pdf.Outlines[index].TargetPageNumber only return -1
Re: pdf.Outlines[index].TargetPageNumber only return -1
Support · Mar 9, 2016Hello,
The DynamicPDF API returns target page number as -1 to those outlines which are added as Parent outlines which do not have direct reference to the page in the PDF. This is expected behavior with DynamicPDF API. If you encounter any outline returning page number as -1 then please check for the child outlines and loop through the child outline list to get the target page number.
If you continue facing problems in retrieving the bookmark information then please send over the following details to [^a|mailto:support@cete.com|opennewwindow|support@cete.com^] so we can look into it further.
1. Input PDF.
2. Code sample to recreate the behavior.
3. Exact version and build number of the DynamicPDF DLL file. You can get this information in DLL references properties (Version and Description fields) in Visual Studio.
4. More details on your requirements.
Thanks,
ceTe Software Support Team.