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 DE18E18B40 for ; Tue, 13 Oct 2015 08:36:12 +0000 (UTC) Received: (qmail 93686 invoked by uid 500); 13 Oct 2015 08:36:12 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 93663 invoked by uid 500); 13 Oct 2015 08:36:12 -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 93652 invoked by uid 99); 13 Oct 2015 08:36:12 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Oct 2015 08:36:12 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id E5211C084E for ; Tue, 13 Oct 2015 08:36:11 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.801 X-Spam-Level: * X-Spam-Status: No, score=1.801 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id syLyvY0OFb3c for ; Tue, 13 Oct 2015 08:36:00 +0000 (UTC) Received: from www168.your-server.de (www168.your-server.de [213.133.104.168]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 51A8620CCD for ; Tue, 13 Oct 2015 08:36:00 +0000 (UTC) Received: from [88.198.220.130] (helo=sslproxy01.your-server.de) by www168.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.80.1) (envelope-from ) id 1Zlv3q-0008Rf-Kk for users@pdfbox.apache.org; Tue, 13 Oct 2015 10:35:54 +0200 Received: from [79.242.104.107] (helo=mbp001.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.84) (envelope-from ) id 1Zlv3n-0000RO-Cv for users@pdfbox.apache.org; Tue, 13 Oct 2015 10:35:51 +0200 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.0 \(3094\)) Subject: Re: Insert Cover Page (2.0.0) From: Maruan Sahyoun In-Reply-To: <561CA7E5.7010709@t-online.de> Date: Tue, 13 Oct 2015 10:35:47 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <9BC0F181-12B7-4537-9B1C-635AF63E67E0@fileaffairs.de> References: <561C16CA.6010609@t-online.de> <07D01B3A-51C9-41C4-8A64-79590EC96020@fileaffairs.de> <561CA7E5.7010709@t-online.de> To: users@pdfbox.apache.org X-Mailer: Apple Mail (2.3094) X-Authenticated-Sender: sahyoun@fileaffairs.de X-Virus-Scanned: Clear (ClamAV 0.98.7/20959/Mon Oct 12 12:05:45 2015) > Am 13.10.2015 um 08:42 schrieb Tilman Hausherr = : >=20 > Am 13.10.2015 um 01:35 schrieb Maruan Sahyoun: >> Hi, >>=20 >> I currently can't try it myself but >>=20 >> PDDocument document =3D PDDocument.load(=E2=80=A6) >> PDPage pageToInsert =3D new PDPage(); >> PDPageTree pageTree =3D document.getPages(); >> COSDictionary pagesDictionary =3D (COSDictionary) = document.getDocumentCatalog().getCOSObject().getDictionaryObject(COSName.P= AGES); >> COSArray kids =3D (COSArray) = pagesDictionary.getDictionaryObject(COSName.KIDS); >> kids.add(0,pageToInsert.getCOSObject()); >> pageToInsert.getCOSObject().setItem(COSName.PARENT, = pagesDictionary); >> pagesDictionary.setInt(COSName.COUNT, = pagesDictionary.getInt(COSName.COUNT) + 1); >> document.save(...); >> document.close(); >=20 > Heh heh, after having looked at the source code, I think this should = work fine. I thought there is some caching, but there isn't. >=20 yes, it does - tried it out this morning. BR Maruan > Tilman >=20 >>=20 >> BR >> Maruan >>=20 >>=20 >>> Am 13.10.2015 um 00:23 schrieb Adam Retter = : >>>=20 >>> Thanks, >>>=20 >>> I have implemented it using merge, but unfortunately that almost >>> doubles my processing time :-( >>>=20 >>> The steps my app takes: >>>=20 >>> 1. I take a PDF of almost 2000 pages and add a footer to each page. >>> This takes about 12 seconds. >>> 2. I then create a PDF which has my single cover page. >>> 3. I merge the two PDFs together. This takes an additional 10 = seconds. >>>=20 >>> I guess that if we had the ability to insert a page then it would be >>> much faster than a merge? >>>=20 >>> On 12 October 2015 at 21:23, Tilman Hausherr = wrote: >>>> Am 12.10.2015 um 22:03 schrieb Adam Retter: >>>>> Hey there, >>>>>=20 >>>>> I want to add a cover page to a PDF, i.e. add a new *first* page = to an >>>>> existing PDF. >>>>>=20 >>>>> I managed this with 1.8.0 by manipulating the page nodes via >>>>> PDPage#setParent, however I can't figure out how to do this with >>>>> 2.0.0-SNAPSHOT. >>>>>=20 >>>>> Can anyone tell me how to insert a new page at index 0 for an = existing >>>>> PDF? >>>>> Perhaps subsequently adding an example to >>>>>=20 >>>>> = https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apac= he/pdfbox/examples/pdmodel/ >>>>> could help others? >>>>=20 >>>> You can't... unless you create a new PDDocument with the cover page = and then >>>> run a merge. >>>>=20 >>>> Your feature request already has an issue: >>>> https://issues.apache.org/jira/browse/PDFBOX-2400 >>>>=20 >>>> Tilman >>>>=20 >>>> = --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org >>>> For additional commands, e-mail: users-help@pdfbox.apache.org >>>>=20 >>>=20 >>>=20 >>> --=20 >>> Adam Retter >>>=20 >>> skype: adam.retter >>> tweet: adamretter >>> http://www.adamretter.org.uk >>>=20 >>> = --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org >>> For additional commands, e-mail: users-help@pdfbox.apache.org >>>=20 >>=20 >=20 >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org > For additional commands, e-mail: users-help@pdfbox.apache.org >=20 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org For additional commands, e-mail: users-help@pdfbox.apache.org