As explained at the following link, PdfSharp currently doesn't read outlines from reader.outlines. We need to go through the PdfObject.
http://stackoverflow.com/questions/1593 ... s-of-a-pdfCurrently I have this code, which is able to access all the outlines, however I am not able to access DestinationPage attached to each outline. It is null.
Code:
using(var inputDocument = PdfReader.Open(@"C:\temp\PdfTemplates\MyPdf.pdf"))
{
PdfDictionary outline = (PdfDictionary)inputDocument.Internals.Catalog.Elements.GetObject("/Outlines");
PdfDictionary first = (PdfDictionary)outline.Elements.GetObject("/First");
PdfDictionary last = (PdfDictionary)outline.Elements.GetObject("/Last");
var iterator = first;
var dict = new Dictionary<string, PdfPage>();
do
{
PdfReference next = iterator.Elements.GetReference("/Next");
if (next != null)
{
PdfOutline nextOutline = new PdfOutline(next.Value as PdfDictionary);
dict.Add(nextOutline.Elements.GetString("/Title"), nextOutline.DestinationPage); // DestinationPage here is null
iterator = nextOutline;
break;
}
}
while (PdfInternals.GetObjectID(iterator) != PdfInternals.GetObjectID(last));
I take we need to do something like getting to "/Dest" object and get the value. However it's a PdfDictionary and can not be typecast to PdfPage.
How do I get to the PdfPage from an outline?