PDFsharp & MigraDoc Forum
https://forum.pdfsharp.net/

How to read the outlines from the existing pdf?
https://forum.pdfsharp.net/viewtopic.php?f=2&t=702
Page 1 of 1

Author:  robertoho [ Sat Apr 11, 2009 6:36 am ]
Post subject:  How to read the outlines from the existing pdf?

I have used the following codes, but it does work:

string filename = "Bookmarks.pdf";
PdfDocument document = PdfReader.Open(filename, PdfDocumentOpenMode.Modify);

PdfOutline.PdfOutlineCollection outlines = document.Outlines;

Console.Writeline(outlines.Count);

The outlines.Count always return 0.

Author:  pinne65 [ Wed May 13, 2009 9:00 pm ]
Post subject:  Plit by Outline / Bookmark

I did pretty much the same thing. Ran the Bookmarks example and then used the output file to try to read in the outlines in order to split the file. But I'm getting a count of 0 (zero) as well.

Author:  bun_zee [ Sun Oct 04, 2009 5:30 am ]
Post subject:  Re: How to read the outlines from the existing pdf?

I got the same kind of error.
Open an existing PDF that has outlines and the PdfDocument.Outlines.Count is zero.
My guess is the PdfDocument.Outlines only knows the outlines during the PDF creation. During the PDF import the Outlines property do not get populated. If this is true then PdfSharp documentation is very very poor.
To access the Outlines of the PdfDocument, use the following:
PdfDocument.Internals.Catalog.Elements.GetObject("/Outlines") and cast the output object to PdfOutline.
To access the title of the outline use PdfOutline.Elements.GetString("/Title")

(PS: these can be found in the source code of the project PdfMerge).

Author:  Jeb [ Thu Dec 03, 2009 4:59 pm ]
Post subject:  Re: How to read the outlines from the existing pdf?

Hello,
i also have the same problem.

i use pdfsharp for concatenation of pdf. Therefore i also want to migrate the old bookmarks.
Therefore i have to read the old ones ...

is there a possibillity to insert cascading bookmarks ?
Something like
Point1
|-Point1.1
|-Point1.2
Point2
|-Point2.1
|-Point2.2

Thanks!

Author:  Thomas Hoevel [ Mon Dec 07, 2009 12:49 pm ]
Post subject:  Re: How to read the outlines from the existing pdf?

Jeb wrote:
is there a possibillity to insert cascading bookmarks?

Yes.

The PdfOutline object contains Outlines. This allows to create a tree of Outlines.

Author:  Jeb [ Mon Dec 07, 2009 2:18 pm ]
Post subject:  Re: How to read the outlines from the existing pdf?

Thanks for that hint.
But my main Problem ist to read the existing outlines of an PDF.
As far as i see, the pdfdocument object doesnt read the outlines...

Author:  Thomas Hoevel [ Mon Dec 07, 2009 2:40 pm ]
Post subject:  Re: How to read the outlines from the existing pdf?

Jeb wrote:
As far as i see, the pdfdocument object doesnt read the outlines...

Not my area of expertise, but I guess bun_zee's post shows how to do that.
viewtopic.php?p=2314#p2314

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/