PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 9:11 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu Apr 10, 2014 5:40 pm 
Offline

Joined: Thu Apr 10, 2014 5:35 pm
Posts: 2
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-pdf

Currently 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?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 143 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group