PDFsharp & MigraDoc Foundation http://forum.pdfsharp.com/ |
|
How to get DestinationPage from Outlines when reading pdf http://forum.pdfsharp.com/viewtopic.php?f=2&t=2789 |
Page 1 of 1 |
Author: | kgvinayak [ Thu Apr 10, 2014 5:40 pm ] |
Post subject: | How to get DestinationPage from Outlines when reading pdf |
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? |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |