Browse Source

Merge pull request #57 from jhonnymertz/pdfbox_update

Updating pdfbox dependency and fixing build warning
Jhonny Mertz 5 years ago
parent
commit
905a9a903f

+ 2 - 2
README.md

@@ -16,7 +16,7 @@ If you are using Gradle/Maven, see example below:
 In your `build.gradle`:
 ```groovy
 dependencies {
-    compile 'com.github.jhonnymertz:java-wkhtmltopdf-wrapper:1.1.10-RELEASE'
+    compile 'com.github.jhonnymertz:java-wkhtmltopdf-wrapper:1.1.11-RELEASE'
 }
 ```
 
@@ -26,7 +26,7 @@ In your `pom.xml`:
 <dependency>
     <groupId>com.github.jhonnymertz</groupId>
     <artifactId>java-wkhtmltopdf-wrapper</artifactId>
-    <version>1.1.10-RELEASE</version>
+    <version>1.1.11-RELEASE</version>
 </dependency>
 ```
 

+ 11 - 4
pom.xml

@@ -3,7 +3,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.github.jhonnymertz</groupId>
     <artifactId>java-wkhtmltopdf-wrapper</artifactId>
-    <version>1.1.10-RELEASE</version>
+    <version>1.1.11-RELEASE</version>
     <packaging>jar</packaging>
 
     <name>Java WkHtmlToPdf Wrapper</name>
@@ -38,18 +38,24 @@
         </developer>
     </developers>
 
+    <properties>
+        <maven.compiler.source>1.7</maven.compiler.source>
+        <maven.compiler.target>1.7</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
     <dependencies>
 
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
-            <version>3.4</version>
+            <version>3.9</version>
         </dependency>
 
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
-            <version>2.5</version>
+            <version>2.6</version>
         </dependency>
 
         <dependency>
@@ -75,7 +81,7 @@
         <dependency>
             <groupId>org.apache.pdfbox</groupId>
             <artifactId>pdfbox</artifactId>
-            <version>1.8.16</version>
+            <version>2.0.16</version>
             <scope>test</scope>
         </dependency>
 
@@ -93,6 +99,7 @@
                     <!-- Show 100% of the lines from the stack trace (doesn't work) -->
                     <trimStackTrace>false</trimStackTrace>
                 </configuration>
+                <version>2.22.1</version>
                 <executions>
                     <execution>
                         <id>unit-tests</id>

+ 5 - 15
src/test/java/com/github/jhonnymertz/wkhtmltopdf/wrapper/integration/PdfIntegrationTests.java

@@ -4,9 +4,8 @@ import com.github.jhonnymertz.wkhtmltopdf.wrapper.Pdf;
 import com.github.jhonnymertz.wkhtmltopdf.wrapper.configurations.WrapperConfig;
 import com.github.jhonnymertz.wkhtmltopdf.wrapper.configurations.XvfbConfig;
 import com.github.jhonnymertz.wkhtmltopdf.wrapper.params.Param;
-import org.apache.pdfbox.pdfparser.PDFParser;
 import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.util.PDFTextStripper;
+import org.apache.pdfbox.text.PDFTextStripper;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -89,13 +88,9 @@ public class PdfIntegrationTests {
     }
 
     private String getPdfTextFromBytes(byte[] pdfBytes) throws IOException {
-        PDFParser parser = new PDFParser(new ByteArrayInputStream(pdfBytes));
+        PDDocument pdDocument = PDDocument.load(new ByteArrayInputStream(pdfBytes));
+        String text = new PDFTextStripper().getText(pdDocument);
 
-        // that is a valid PDF (otherwise an IOException occurs)
-        parser.parse();
-        PDFTextStripper pdfTextStripper = new PDFTextStripper();
-        PDDocument pdDocument = new PDDocument(parser.getDocument());
-        String text = pdfTextStripper.getText(pdDocument);
         pdDocument.close();
         return text;
     }
@@ -128,13 +123,8 @@ public class PdfIntegrationTests {
 
         // WHEN
         byte[] pdfBytes = pdf.getPDF();
-
-        PDFParser parser = new PDFParser(new ByteArrayInputStream(pdfBytes));
-
-        // that is a valid PDF (otherwise an IOException occurs)
-        parser.parse();
-        PDFTextStripper pdfTextStripper = new PDFTextStripper();
-        String pdfText = pdfTextStripper.getText(new PDDocument(parser.getDocument()));
+        PDDocument pdDocument = PDDocument.load(new ByteArrayInputStream(pdfBytes));
+        String pdfText = new PDFTextStripper().getText(pdDocument);
 
         Assert.assertThat("document should be generated", pdfText, containsString("Google"));
     }