pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1884336 - in /pdfbox/trunk/pdfbox/src: main/java/org/apache/pdfbox/pdmodel/fixup/processor/AcroFormGenerateAppearancesProcessor.java test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormGenerateAppearancesTest.java
Date Fri, 11 Dec 2020 19:09:34 GMT
Author: msahyoun
Date: Fri Dec 11 19:09:34 2020
New Revision: 1884336

URL: http://svn.apache.org/viewvc?rev=1884336&view=rev
Log:
PDFBOX-5042: avoid IllegalArgumentException in AcroFormGenerateAppearancesProcessor

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fixup/processor/AcroFormGenerateAppearancesProcessor.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormGenerateAppearancesTest.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fixup/processor/AcroFormGenerateAppearancesProcessor.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fixup/processor/AcroFormGenerateAppearancesProcessor.java?rev=1884336&r1=1884335&r2=1884336&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fixup/processor/AcroFormGenerateAppearancesProcessor.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fixup/processor/AcroFormGenerateAppearancesProcessor.java
Fri Dec 11 19:09:34 2020
@@ -52,10 +52,10 @@ public class AcroFormGenerateAppearances
                 acroForm.refreshAppearances();
                 acroForm.setNeedAppearances(false);
             }
-            catch (IOException ioe)
+            catch (IOException | IllegalArgumentException ex)
             {
                 LOG.debug("couldn't generate appearance stream for some fields - check output");
-                LOG.debug(ioe.getMessage());
+                LOG.debug(ex.getMessage());
             }
         } 
     }

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormGenerateAppearancesTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormGenerateAppearancesTest.java?rev=1884336&r1=1884335&r2=1884336&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormGenerateAppearancesTest.java
(original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroFormGenerateAppearancesTest.java
Fri Dec 11 19:09:34 2020
@@ -23,7 +23,6 @@ import java.io.IOException;
 import java.net.URL;
 
 import org.apache.pdfbox.Loader;
-import org.apache.pdfbox.io.IOUtils;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
 import org.junit.jupiter.api.Test;
@@ -38,20 +37,30 @@ public class PDAcroFormGenerateAppearanc
     @Test
     public void test5041MissingFontDescriptor() throws IOException
     {
-
         String sourceUrl = "https://issues.apache.org/jira/secure/attachment/13016941/REDHAT-1301016-0.pdf";
 
-        PDDocument testPdf = null;
-        try
+        try (PDDocument testPdf = Loader.loadPDF(new URL(sourceUrl).openStream()))
         {
-            testPdf = Loader.loadPDF(new URL(sourceUrl).openStream());
             PDDocumentCatalog catalog = testPdf.getDocumentCatalog();
 
             assertDoesNotThrow(() -> catalog.getAcroForm(), "Getting the AcroForm shall
not throw an exception");
         }
-        finally
+    }
+
+    /**
+     * PDFBOX-4086 Character missing for encoding
+     * @throws IOException
+     */
+    @Test
+    public void test4086CharNotEncodable() throws IOException
+    {
+        String sourceUrl = "https://issues.apache.org/jira/secure/attachment/12908175/AML1.PDF";
+
+        try (PDDocument testPdf = Loader.loadPDF(new URL(sourceUrl).openStream()))
         {
-            IOUtils.closeQuietly(testPdf);
+            PDDocumentCatalog catalog = testPdf.getDocumentCatalog();
+
+            assertDoesNotThrow(() -> catalog.getAcroForm(), "Getting the AcroForm shall
not throw an exception");
         }
-    } 
+    }
 }



Mime
View raw message