View previous topic :: View next topic |
Author |
Message |
jiuqiangjiang
Joined: 30 Mar 2007 Posts: 1
|
Posted: Sat Mar 31, 2007 3:02 am Post subject: how to get a pdf document outlines |
|
|
I want to get outlines from a exist document and I write code like
this:
PdfDocument pdfFile = PdfReader.Open(@"C:\Downloads\pdf_reference.pdf", PdfDocumentOpenMode.Import);
PdfOutline.PdfOutlineCollection outlineCollection = pdfFile.Outlines;
foreach (PdfOutline outline in outlineCollection)
{
System.Console.WriteLine(outline.Title);
}
and then raise a error :
no appropriate constructor fond for type:PdfOutline
now,how can I solve my problem?
thanks! _________________ study.......... |
|
Back to top |
|
|
IQDragon
Joined: 11 Jul 2007 Posts: 1
|
Posted: Wed Jul 11, 2007 1:06 pm Post subject: Outlines |
|
|
This is correct, to my knowledge a lot of stuff won't work with existing PDF documents.
I downloaded the 0.9.653 code myself (only can use .NET 1.1 for this project) and found that error to.
The trick is to have the following constructor:
public PdfOutline(PdfDictionary dictionary) : base(dictionary)
{
}
This does not fix the issue with existing outlines, you'll soon notice it retuning an empty collection.
If you need a fix for this let me know I'll be happy to share it.
It did take considerable time to find a workaround though lol. |
|
Back to top |
|
|
ACS
Joined: 01 Dec 2007 Posts: 15
|
Posted: Tue Dec 04, 2007 5:41 am Post subject: |
|
|
I'm actually looking for a fix for this as well. I need to access the outline structure of an existing PDF and it's very frustrating that I can't do it!
IQDragon, if you have a fix, please share! |
|
Back to top |
|
|
cvanling
Joined: 11 Jan 2008 Posts: 5
|
Posted: Sun Feb 17, 2008 7:23 pm Post subject: Outlines |
|
|
It can be done using PdfSharp, but a little coding is required.
First you need to access the document outline:
// get the outline object
PdfDictionary outline = (PdfDictionary)inputDocument.Internals.Catalog.Elements.GetObject("/Outlines");
// you can then access the first outline using:
PdfDictionary first = (PdfDictionary)outline.Elements.GetObject("/First");
// you can then access the title of the first outline using:
string title = first.Elements.GetString("/Title");
There is a fully worked out demo for this on sourceforge (see the pdfmerge project). It gets a little complicated because there are lot of variations in outline formats, especially for new acrobat documents which support outlining to various points on a single page. |
|
Back to top |
|
|
|