pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marvin B. Lillehaug" <marvin.lilleh...@gmail.com>
Subject Merge PDFs, add second pdf as child in outline
Date Tue, 09 Apr 2013 09:34:35 GMT
I am trying to create a single pdf from a hierarchy of previously generated
pdfs, and having some problems with the outline.
I have two pdfs, one for the parent and one for its children, and want to
add the existing outline of the children as the child of the existing
outline for the parent.

My current code is
// load pdfs here
PDFMergerUtility pdfMergerUtility = new PDFMergerUtility();
pdfMergerUtility.appendDocument(pdf, attachment);

PDDocumentOutline documentOutline =
PDOutlineItem originalRoot = documentOutline.getFirstChild();
PDOutlineItem appendedRoot = originalRoot.getNextSibling();

//save pdf here

The resulting pdf looks like it is supposed to and the outline is working,
i.e. clicking on a node jumps to the correct page. But the children are
duplicated, they show as both children and siblings of the outline from the
parent pdf.

In all my attempts that resulted in the outline looking like it should,
clicking on the outline nodes had no effect.

Any pointers?

Marvin B. Lillehaug

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