From e72fe3683ce9c5da21874ca918aad2f3e06f72a2 Mon Sep 17 00:00:00 2001 From: jendib Date: Sat, 5 Sep 2015 23:12:01 +0200 Subject: [PATCH] #4: Upgrade to unrelease PDFBox 2 --- .../java/com/sismics/docs/core/util/FileUtil.java | 13 ++++--------- docs-parent/pom.xml | 14 +++++++++++++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/docs-core/src/main/java/com/sismics/docs/core/util/FileUtil.java b/docs-core/src/main/java/com/sismics/docs/core/util/FileUtil.java index 5e47124f..702160b3 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/util/FileUtil.java +++ b/docs-core/src/main/java/com/sismics/docs/core/util/FileUtil.java @@ -8,7 +8,6 @@ import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.List; import javax.crypto.Cipher; import javax.crypto.CipherInputStream; @@ -16,8 +15,8 @@ import javax.crypto.CipherOutputStream; import javax.imageio.ImageIO; import org.apache.pdfbox.pdmodel.PDDocument; -import org.apache.pdfbox.pdmodel.PDPage; -import org.apache.pdfbox.util.PDFTextStripper; +import org.apache.pdfbox.rendering.PDFRenderer; +import org.apache.pdfbox.text.PDFTextStripper; import org.imgscalr.Scalr; import org.imgscalr.Scalr.Method; import org.imgscalr.Scalr.Mode; @@ -159,12 +158,8 @@ public class FileUtil { PDDocument pdfDocument = null; try { pdfDocument = PDDocument.load(inputStream, true); - @SuppressWarnings("unchecked") - List pageList = pdfDocument.getDocumentCatalog().getAllPages(); - if (pageList.size() > 0) { - PDPage page = pageList.get(0); - image = page.convertToImage(); - } + PDFRenderer renderer = new PDFRenderer(pdfDocument); + image = renderer.renderImage(0); } finally { pdfDocument.close(); } diff --git a/docs-parent/pom.xml b/docs-parent/pom.xml index dd6eaf53..d9ac4901 100644 --- a/docs-parent/pom.xml +++ b/docs-parent/pom.xml @@ -35,7 +35,7 @@ 4.2.0 1.0.5 4.2 - 1.8.10 + 2.0.0-SNAPSHOT 1.49 1.9.18-m @@ -73,6 +73,18 @@ HEAD + + + ApacheSnapshot + Apache Repository + https://repository.apache.org/content/groups/snapshots/ + + true + + + + +