You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2018/05/17 20:29:14 UTC

svn commit: r1831811 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java

Author: tilman
Date: Thu May 17 20:29:14 2018
New Revision: 1831811

URL: http://svn.apache.org/viewvc?rev=1831811&view=rev
Log:
PDFBOX-4222: ignore all page labels if there is a bad entry (similar to Adobe Reader)

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java?rev=1831811&r1=1831810&r2=1831811&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/multipdf/PDFMergerUtility.java Thu May 17 20:29:14 2018
@@ -619,12 +619,18 @@ public class PDFMergerUtility
             COSArray srcNums = (COSArray) srcLabels.getDictionaryObject(COSName.NUMS);
             if (srcNums != null)
             {
+                int startSize = destNums.size();
                 for (int i = 0; i < srcNums.size(); i += 2)
                 {
                     COSBase base = srcNums.getObject(i);
                     if (!(base instanceof COSNumber))
                     {
-                        LOG.warn("page labels skipped at index " + i + ", should be a number, but is " + base);
+                        LOG.error("page labels ignored, index " + i + " should be a number, but is " + base);
+                        // remove what we added
+                        while (destNums.size() > startSize)
+                        {
+                            destNums.remove(startSize);
+                        }
                         break;
                     }
                     COSNumber labelIndex = (COSNumber) base;