pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Grosso <gary.gro...@oberontech.com>
Subject RE: how to create an entire bookmark (outline) tree in an existing PDF document?
Date Fri, 28 Aug 2015 16:11:56 GMT
Thanks, Gilad.

Further extensive Googling also turned up “Source Code of org.apache.pdfbox.examples.pdmodel.CreateBookmarks”
at http://massapi.com/source/github/74/69/746955461/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateBookmarks.java.html#67
which together with your overview should get me started.

I’ll report back on my progress.

Gary

From: Gilad Denneboom [mailto:gilad.denneboom@gmail.com]
Sent: Friday, August 28, 2015 12:04 PM
To: users@pdfbox.apache.org
Cc: Gary Grosso <gary.grosso@oberontech.com>
Subject: Re: how to create an entire bookmark (outline) tree in an existing PDF document?

Create a new PDDocumentOutline object, and then add all of your PDOutlineNode children under
it.
When done, access the file's PDDocumentCatalog and use the setDocumentOutline method to attach
your bookmarks outline object to the document.
I didn't try doing it from scratch, but I believe it should work.

On Fri, Aug 28, 2015 at 5:54 PM, Gary Grosso <gary.grosso@oberontech.com<mailto:gary.grosso@oberontech.com>>
wrote:
Greetings knowledgeable ones,

I'm new to PDFbox, and am under some time pressure to get back to a customer  with confirmation
we can do what they want and a rough estimate.

For background, they have a single PDF file that is a master TOC linking to hundreds of subordinate
topic PDFs. They would like each such topic PDF to have bookmarks which would essentially
parallel the master TOC, such that an end user can click a bookmark in any topic PDF to navigate
to any other topic PDF.

I am creating this master TOC, using proprietary software, so I have the data "in hand" -
what the titles and hierarchy are, and what the filenames are each one should link to. This
proprietary software does not have the capability to generate the desired bookmarks in the
topic PDFs - it can only generate internal links to items within the current PDF document
-- but it does have the ability to call a Java application, so that is where I want to use
PDFbox, to post-process the topic-PDF output and add the bookmarks.

I've  been browsing through the Javadoc, and I'm pretty sure I need to be working with PDOutlineNode
and PDOutlineItem. I can see methods which sound like they could be used to add more items
and sub-nodes to the tree, but I'm not seeing how to link the tree into the document to begin
with.  There is not much in the way of example code or cookbook-type references, and what
I do find is 90% about reading PDFs and very little about modifying/augmenting them. So, I
could really use some help knowing how to get started.

I could create these topic PDFs with no bookmarks at all, or generate them with one bookmark
to the top of page 1, whichever is easier to work with. (I'm thinking it may be easier if
I have a sort of placeholder to start with.)

Thanks for any help,
Gary

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message