PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Apr 19, 2024 12:30 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sat Mar 31, 2007 3:02 am 
Offline

Joined: Fri Mar 30, 2007 6:30 am
Posts: 1
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..........


Top
 Profile  
Reply with quote  
 Post subject: Outlines
PostPosted: Wed Jul 11, 2007 1:06 pm 
Offline

Joined: Wed Jul 11, 2007 1:00 pm
Posts: 1
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 04, 2007 5:41 am 
Offline

Joined: Sat Dec 01, 2007 7:22 pm
Posts: 15
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!


Top
 Profile  
Reply with quote  
 Post subject: Outlines
PostPosted: Sun Feb 17, 2008 7:23 pm 
Offline

Joined: Fri Jan 11, 2008 6:15 pm
Posts: 5
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.


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 12, 2013 2:02 pm 
Offline

Joined: Thu Apr 11, 2013 8:56 am
Posts: 1
Ok.But how to show all bookmarks?With help of your code i wirte this
Code:
ICollection<String> s =outline.Elements.Keys;

In this Keys is only the name of the first outline (plus "/Count","First","Last").


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 19, 2013 12:45 pm 
Offline

Joined: Fri Apr 05, 2013 6:42 pm
Posts: 10
There is a PDFMerge project that has an AddBookmarksFromFile function that gets a file's outline items. Look at that.

download the source here.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 241 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