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 1136418168 for ; Mon, 28 Sep 2015 15:20:25 +0000 (UTC) Received: (qmail 76833 invoked by uid 500); 28 Sep 2015 15:20:22 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 76807 invoked by uid 500); 28 Sep 2015 15:20:22 -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 76795 invoked by uid 99); 28 Sep 2015 15:20:22 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Sep 2015 15:20:22 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id AB9901800B2 for ; Mon, 28 Sep 2015 15:20:21 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.802 X-Spam-Level: X-Spam-Status: No, score=0.802 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, LOTS_OF_MONEY=0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id N1dEeBbaU5W6 for ; Mon, 28 Sep 2015 15:20:07 +0000 (UTC) Received: from us-smtp-delivery-105.mimecast.com (us-smtp-delivery-105.mimecast.com [63.128.21.105]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 9484E20F4B for ; Mon, 28 Sep 2015 15:20:06 +0000 (UTC) Received: from hubca1.pgac.com (email.pgac.com [12.68.231.192]) (Using TLS) by us-smtp-1.mimecast.com with ESMTP id us-mta-40-IwBTpbPiSsKzt28Se-TB7w-167; Mon, 28 Sep 2015 11:19:56 -0400 Received: from EX07MAIL3.pgac.com ([172.23.10.5]) by hubca1.pgac.com ([172.23.10.3]) with mapi; Mon, 28 Sep 2015 10:18:58 -0500 From: Kevin Ternes To: "users@pdfbox.apache.org" Date: Mon, 28 Sep 2015 10:18:57 -0500 Subject: RE: Two problems with merged documents. Thread-Topic: Two problems with merged documents. Thread-Index: AdD2gSXoDgvTEelRSgmBCDDwPQ/SPwDf8UJA Message-ID: References: <9F1F4ED6-E954-4AF4-BF9B-119930A93CAA@fileaffairs.de> <50271D4C-F841-4F9F-AB3F-81233A04EAAB@fileaffairs.de> In-Reply-To: <50271D4C-F841-4F9F-AB3F-81233A04EAAB@fileaffairs.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 X-MC-Unique: IwBTpbPiSsKzt28Se-TB7w-167 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Excellent. I have had good luck with that build. Thank you both. -----Original Message----- From: Maruan Sahyoun [mailto:sahyoun@fileaffairs.de]=20 Sent: Wednesday, September 23, 2015 11:00 PM To: users@pdfbox.apache.org Subject: Re: Two problems with merged documents. Hi Kevin, Tilmans fix also fixed the issue when merging documents. BR Maruan > Am 22.09.2015 um 21:09 schrieb Kevin Ternes : >=20 > Yes, the last one, output/3-flattened-merged-A.pdf is missing field value= s. >=20 > -----Original Message----- > From: Maruan Sahyoun [mailto:sahyoun@fileaffairs.de]=20 > Sent: Tuesday, September 22, 2015 1:35 PM > To: users@pdfbox.apache.org > Subject: Re: Two problems with merged documents. >=20 > Hi Kevin, >=20 > just to be sure - the individual files are OK but the merged one is the o= ne where the content is missing? >=20 > BR > Maruan >=20 >> Am 22.09.2015 um 19:52 schrieb Kevin Ternes : >>=20 >> I still have two problems with the merge. >> First is the problem of losing field values after the merge which I have= had all along. >> The second is new and is that when I open the merge document with Adobe = Reader XI (11.0.12) I see a popup saying "Out of Memory". >> That popup usually appears after scrolling down the merged document. >>=20 >> Four source documents are here: >> https://dl.dropboxusercontent.com/u/3103884/dev/EndFaxCover_CA.pdf >> https://dl.dropboxusercontent.com/u/3103884/dev/EndDetails_CA.pdf >> https://dl.dropboxusercontent.com/u/3103884/dev/EndExclDrv_CA.pdf >> https://dl.dropboxusercontent.com/u/3103884/dev/EndSig_CA.pdf >>=20 >> The following code loads and populates the documents and then flattens a= nd merges them. >> Whether or not the flatten() is called does not make a difference. =20 >> If someone can have a look, I'd really appreciate it. >>=20 >> import java.io.File; >> import java.util.Date; >>=20 >> import org.apache.pdfbox.multipdf.PDFMergerUtility; >> import org.apache.pdfbox.pdmodel.PDDocument; >> import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm; >> import org.apache.pdfbox.pdmodel.interactive.form.PDCheckbox; >> import org.apache.pdfbox.pdmodel.interactive.form.PDTextField; >>=20 >> public class PDFBoxRun { >>=20 >> public static void main(String[] args) { >>=20 >> System.out.println("Running..."); >> PDDocument pdDocumentA =3D null; >> PDDocument pdDocumentB =3D null; >> PDDocument pdDocumentC =3D null; >> PDDocument pdDocumentD =3D null; >>=20 >> try { >>=20 >> pdDocumentA =3D PDDocument.load(new File("template/EndFaxCover_CA.pd= f")); >> PDAcroForm acroForm =3D pdDocumentA.getDocumentCatalog().getAcroForm= (); >> ((PDCheckbox) acroForm.getField("boxUMPD")).check(); >> ((PDTextField) acroForm.getField("printDate")).setValue("09/11/2015"= ); >> ((PDTextField) acroForm.getField("polNum")).setValue("22-CA-116850A"= ); >> ((PDTextField) acroForm.getField("quoteEffDt")).setValue("09/11/2015= "); >> ((PDTextField) acroForm.getField("agencyName")).setValue("THE MAJOR1= 23 AUTO INS SVCS, INC"); >> ((PDTextField) acroForm.getField("quoteNum")).setValue("2917812"); >>=20 >> pdDocumentB =3D PDDocument.load(new File("template/EndDetails_CA.pdf= ")); >> acroForm =3D pdDocumentB.getDocumentCatalog().getAcroForm(); >> ((PDTextField) acroForm.getField("hdrAuditFld")).setValue("Generated= at " + new Date() + ", User: DEVUSER/PDFBoxRun]"); >> ((PDTextField) acroForm.getField("quoteOrBindHdr")).setValue("Policy= Change Request (Quote Only)"); >> ((PDTextField) acroForm.getField("endEffDt")).setValue("09/04/2015")= ; >> ((PDTextField) acroForm.getField("endEffTime")).setValue("11:59 PM")= ; >> ((PDTextField) acroForm.getField("polnum")).setValue("22-CA-116850A = (quote 2917812)"); >> ((PDTextField) acroForm.getField("agencyDesc")).setValue("THE MAJOR1= 23 AUTO INS SVCS, INC (998888)"); >> ((PDTextField) acroForm.getField("hInsName")).setValue("EXAMPLE N SU= REDNAME"); >> ((PDTextField) acroForm.getField("BIPDLim")).setValue("$15,000/$30,0= 00/$10,000"); >> ((PDTextField) acroForm.getField("MedPay")).setValue("No coverage"); >> ((PDTextField) acroForm.getField("UMBI")).setValue("$15,000/$30,000"= ); >> ((PDTextField) acroForm.getField("UMPD")).setValue("No coverage"); >>=20 >> pdDocumentC =3D PDDocument.load(new File("template/EndSig_CA.pdf")); >> acroForm =3D pdDocumentC.getDocumentCatalog().getAcroForm(); >> ((PDTextField) acroForm.getField("hdrAuditFld")).setValue("Generated= at " + new Date() + ", User: DEVUSER/PDFBoxRun"); >> ((PDTextField) acroForm.getField("quoteOrBindHdr")).setValue("Policy= Change Request (Quote Only)]"); >> ((PDTextField) acroForm.getField("endEffDt")).setValue("09/04/2015")= ; >> ((PDTextField) acroForm.getField("endEffTime")).setValue("11:59 PM")= ; >> ((PDTextField) acroForm.getField("polnum")).setValue("[22-CA-116850A= (quote 2917812)"); >> ((PDTextField) acroForm.getField("agencyDesc")).setValue("THE MAJOR1= 23 AUTO INS SVCS, INC (998888)"); >> ((PDTextField) acroForm.getField("hInsName")).setValue("EXAMPLE N SU= REDNAME"); >> ((PDTextField) acroForm.getField("umpdRejSigAppl")).setValue("XXXX")= ; >>=20 >> pdDocumentD =3D PDDocument.load(new File("template/EndExclDrv_CA.pdf= ")); >> acroForm =3D pdDocumentD.getDocumentCatalog().getAcroForm(); >> ((PDTextField) acroForm.getField("hdrAuditFld")).setValue("Generated= at " + new Date() + ", User: DEVUSER/PDFBoxRun"); >> ((PDTextField) acroForm.getField("quoteOrBindHdr")).setValue("Policy= Change Request (Quote Only)]"); >> ((PDTextField) acroForm.getField("endEffDt")).setValue("09/04/2015")= ; >> ((PDTextField) acroForm.getField("endEffTime")).setValue("11:59 PM")= ; >> ((PDTextField) acroForm.getField("hInsName")).setValue("EXAMPLE N SU= REDNAME"); >> ((PDTextField) acroForm.getField("polnum")).setValue("[22-CA-116850A= (quote 2917812)"); >> ((PDTextField) acroForm.getField("agencyDesc")).setValue("THE MAJOR1= 23 AUTO INS SVCS, INC (998888)"); >>=20 >> pdDocumentA.save("output/0-Afilled-EndFaxCover_CA.pdf"); >> pdDocumentB.save("output/0-Bfilled-EndDetails_CA.pdf"); >> pdDocumentC.save("output/0-Cfilled-EndSig_CA.pdf"); >> pdDocumentD.save("output/0-Dfilled-EndExclDrv_CA.pdf"); >>=20 >> pdDocumentA.getDocumentCatalog().getAcroForm().flatten(); >> pdDocumentB.getDocumentCatalog().getAcroForm().flatten(); >> pdDocumentC.getDocumentCatalog().getAcroForm().flatten(); >> pdDocumentD.getDocumentCatalog().getAcroForm().flatten(); >>=20 >> pdDocumentA.save("output/2-Aflattened-EndFaxCover_CA.pdf"); >> pdDocumentB.save("output/2-Bflattened-EndDetails_CA.pdf"); >> pdDocumentC.save("output/2-Cflattened-EndSig_CA.pdf"); >> pdDocumentD.save("output/2-Dflattened-EndExclDrv_CA.pdf"); >>=20 >> System.out.println("Merging..."); >> PDFMergerUtility mergerUtility =3D new PDFMergerUtility(); >> mergerUtility.appendDocument(pdDocumentA, pdDocumentB); >> mergerUtility.appendDocument(pdDocumentA, pdDocumentC); >> mergerUtility.appendDocument(pdDocumentA, pdDocumentD); >> System.out.println("Saving merged document as output/3-flattened-mer= ged-A.pdf"); >> pdDocumentA.save("output/3-flattened-merged-A.pdf"); >>=20 >> System.out.println("Done."); >> } catch (Exception ex) { >> System.err.println("Caught " + ex); >> ex.printStackTrace(); >> } finally { >> close(pdDocumentA); >> close(pdDocumentB); >> close(pdDocumentC); >> close(pdDocumentD); >> } >> } >>=20 >> static void close(PDDocument doc) { >> if (null !=3D doc) { >> try { doc.close(); } catch (Exception ex) { } >> } >> } >>=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 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org For additional commands, e-mail: users-help@pdfbox.apache.org