Return-Path: X-Original-To: apmail-pdfbox-commits-archive@www.apache.org Delivered-To: apmail-pdfbox-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 88B0B197D1 for ; Sat, 16 Apr 2016 20:51:16 +0000 (UTC) Received: (qmail 94403 invoked by uid 500); 16 Apr 2016 20:51:16 -0000 Delivered-To: apmail-pdfbox-commits-archive@pdfbox.apache.org Received: (qmail 94377 invoked by uid 500); 16 Apr 2016 20:51:16 -0000 Mailing-List: contact commits-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list commits@pdfbox.apache.org Received: (qmail 94368 invoked by uid 99); 16 Apr 2016 20:51:16 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Apr 2016 20:51:16 +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 9D89BC0E26 for ; Sat, 16 Apr 2016 20:51:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.999 X-Spam-Level: X-Spam-Status: No, score=0.999 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id aNpu7AWcVa_7 for ; Sat, 16 Apr 2016 20:51:13 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTP id 07C5C5F480 for ; Sat, 16 Apr 2016 20:51:13 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 1ED64E0054 for ; Sat, 16 Apr 2016 20:51:12 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id C32D03A0216 for ; Sat, 16 Apr 2016 20:51:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1739510 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java Date: Sat, 16 Apr 2016 20:51:11 -0000 To: commits@pdfbox.apache.org From: tilman@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160416205111.C32D03A0216@svn01-us-west.apache.org> Author: tilman Date: Sat Apr 16 20:51:11 2016 New Revision: 1739510 URL: http://svn.apache.org/viewvc?rev=1739510&view=rev Log: PDFBOX-3317: copy outputIntents, avoid certain duplicates Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java?rev=1739510&r1=1739509&r2=1739510&view=diff ============================================================================== --- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java (original) +++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java Sat Apr 16 20:51:11 2016 @@ -49,6 +49,7 @@ import org.apache.pdfbox.pdmodel.common. import org.apache.pdfbox.pdmodel.common.PDStream; import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDMarkInfo; import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureTreeRoot; +import org.apache.pdfbox.pdmodel.graphics.color.PDOutputIntent; import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation; import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDDocumentOutline; import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem; @@ -429,6 +430,8 @@ public class PDFMergerUtility destCatalog.getCOSObject().setItem(COSName.METADATA, newStream); } + mergeOutputIntents(cloner, srcCatalog, destCatalog); + // merge logical structure hierarchy if logical structure information is available in both source pdf and // destination pdf boolean mergeStructTree = false; @@ -538,6 +541,38 @@ public class PDFMergerUtility } } + // copy outputIntents to destination, but avoid duplicate OutputConditionIdentifier, + // except when it is missing or is named "Custom". + private void mergeOutputIntents(PDFCloneUtility cloner, + PDDocumentCatalog srcCatalog, PDDocumentCatalog destCatalog) throws IOException + { + List srcOutputIntents = srcCatalog.getOutputIntents(); + List dstOutputIntents = destCatalog.getOutputIntents(); + for (PDOutputIntent srcOI : srcOutputIntents) + { + String srcOCI = srcOI.getOutputConditionIdentifier(); + if (srcOCI != null && !"Custom".equals(srcOCI)) + { + // is that identifier already there? + boolean skip = false; + for (PDOutputIntent dstOI : dstOutputIntents) + { + if (dstOI.getOutputConditionIdentifier().equals(srcOCI)) + { + skip = true; + break; + } + } + if (skip) + { + continue; + } + } + destCatalog.addOutputIntent(new PDOutputIntent((COSDictionary) cloner.cloneForNewDocument(srcOI))); + dstOutputIntents.add(srcOI); + } + } + private int nextFieldNum = 1; /**