Return-Path: X-Original-To: apmail-pdfbox-users-archive@www.apache.org Delivered-To: apmail-pdfbox-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 47E1B100DB for ; Tue, 9 Apr 2013 10:00:16 +0000 (UTC) Received: (qmail 3796 invoked by uid 500); 9 Apr 2013 10:00:16 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 3163 invoked by uid 500); 9 Apr 2013 10:00:15 -0000 Mailing-List: contact users-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@pdfbox.apache.org Delivered-To: mailing list users@pdfbox.apache.org Received: (qmail 2712 invoked by uid 99); 9 Apr 2013 10:00:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Apr 2013 10:00:14 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [213.133.104.168] (HELO www168.your-server.de) (213.133.104.168) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Apr 2013 10:00:07 +0000 Received: from [78.46.4.229] (helo=sslproxy03.your-server.de) by www168.your-server.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.74) (envelope-from ) id 1UPVL7-0001kE-NR for users@pdfbox.apache.org; Tue, 09 Apr 2013 11:59:45 +0200 Received: from [93.207.106.218] (helo=mbp001.fritz.box) by sslproxy03.your-server.de with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UPVL4-0006HU-HC for users@pdfbox.apache.org; Tue, 09 Apr 2013 11:59:42 +0200 From: Maruan Sahyoun Content-Type: multipart/alternative; boundary="Apple-Mail=_6FA3CB9D-4718-4FB2-ACCB-30DEEC15194A" Message-Id: Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Subject: Re: Merge PDFs, add second pdf as child in outline Date: Tue, 9 Apr 2013 11:59:39 +0200 References: To: users@pdfbox.apache.org In-Reply-To: X-Mailer: Apple Mail (2.1503) X-Authenticated-Sender: sahyoun@fileaffairs.de X-Virus-Scanned: Clear (ClamAV 0.97.6/16982/Tue Apr 9 06:42:26 2013) X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail=_6FA3CB9D-4718-4FB2-ACCB-30DEEC15194A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi Marvin, first I have to say that from your description I didn't fully get what = you would like to achieve and which result you get.=20 The PDFMergerUtility already appends the outline of your children as a = child to the outline of your parent. That's why you get it twice. =46rom the source: PDDocumentOutline destOutline =3D = destCatalog.getDocumentOutline(); PDDocumentOutline srcOutline =3D = srcCatalog.getDocumentOutline(); if( srcOutline !=3D null ) { if( destOutline =3D=3D null ) { PDDocumentOutline cloned =3D new PDDocumentOutline( = (COSDictionary)cloner.cloneForNewDocument( srcOutline ) ); destCatalog.setDocumentOutline( cloned ); } else { PDOutlineItem first =3D srcOutline.getFirstChild(); if(first !=3D null) { PDOutlineItem clonedFirst =3D new PDOutlineItem( (COSDictionary)cloner.cloneForNewDocument( = first )); destOutline.appendChild( clonedFirst ); } } } BR Maruan Sahyoun Am 09.04.2013 um 11:34 schrieb Marvin B. Lillehaug = : > 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. >=20 > My current code is > // load pdfs here > PDFMergerUtility pdfMergerUtility =3D new PDFMergerUtility(); > pdfMergerUtility.appendDocument(pdf, attachment); >=20 > PDDocumentOutline documentOutline =3D > pdf.getDocumentCatalog().getDocumentOutline(); > PDOutlineItem originalRoot =3D documentOutline.getFirstChild(); > PDOutlineItem appendedRoot =3D originalRoot.getNextSibling(); > originalRoot.appendChild(appendedRoot); >=20 > //save pdf here >=20 > 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. >=20 > In all my attempts that resulted in the outline looking like it = should, > clicking on the outline nodes had no effect. >=20 > Any pointers? >=20 > --=20 > mvh, > Marvin B. Lillehaug --Apple-Mail=_6FA3CB9D-4718-4FB2-ACCB-30DEEC15194A--