From a88b8b258de0f17f975704f309b1a8b5c877a03f Mon Sep 17 00:00:00 2001 From: Koda Date: Thu, 15 Sep 2016 21:50:34 +0900 Subject: [PATCH] Upgrade pdfbox for use japanese font --- pom.xml | 2 +- .../parser/impl/PdfSlideShowParserOnPdfbox.java | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 5a9db32a4..94694167f 100644 --- a/pom.xml +++ b/pom.xml @@ -126,7 +126,7 @@ org.apache.tika tika-parsers - 1.12 + 1.13 org.ow2.asm diff --git a/src/main/java/org/support/project/knowledge/parser/impl/PdfSlideShowParserOnPdfbox.java b/src/main/java/org/support/project/knowledge/parser/impl/PdfSlideShowParserOnPdfbox.java index 0597e6872..896b1b06f 100644 --- a/src/main/java/org/support/project/knowledge/parser/impl/PdfSlideShowParserOnPdfbox.java +++ b/src/main/java/org/support/project/knowledge/parser/impl/PdfSlideShowParserOnPdfbox.java @@ -3,11 +3,11 @@ import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; -import java.util.List; import org.apache.pdfbox.pdmodel.PDDocument; -import org.apache.pdfbox.pdmodel.PDPage; -import org.apache.pdfbox.util.ImageIOUtil; +import org.apache.pdfbox.rendering.ImageType; +import org.apache.pdfbox.rendering.PDFRenderer; +import org.apache.pdfbox.tools.imageio.ImageIOUtil; import org.support.project.common.exception.ParseException; import org.support.project.knowledge.parser.SlideShowParser; @@ -18,7 +18,6 @@ public void parse(File inputFile, File outputDir) throws ParseException { try { /* * Solution for the 1.8 version: - */ PDDocument document = PDDocument.loadNonSeq(inputFile, null); List pdPages = document.getDocumentCatalog().getAllPages(); int page = 0; @@ -28,9 +27,11 @@ public void parse(File inputFile, File outputDir) throws ParseException { ImageIOUtil.writeImage(bim, outputDir.getAbsolutePath() + "/" + page + ".png", 300); } document.close(); + */ /* * Solution for the 2.0 version: + */ PDDocument document = PDDocument.load(inputFile); PDFRenderer pdfRenderer = new PDFRenderer(document); for (int page = 0; page < document.getNumberOfPages(); ++page) { @@ -40,8 +41,6 @@ public void parse(File inputFile, File outputDir) throws ParseException { ImageIOUtil.writeImage(bim, outputDir.getAbsolutePath() + "/" + (page + 1) + ".png", 300); } document.close(); - */ - } catch (IOException e) { throw new ParseException(e); }