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
Hi!
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 =
pdf.getDocumentCatalog().getDocumentOutline();
PDOutlineItem originalRoot = documentOutline.getFirstChild();
PDOutlineItem appendedRoot = originalRoot.getNextSibling();
originalRoot.appendChild(appendedRoot);

//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?

-- 
mvh,
Marvin B. Lillehaug

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