Skip to content

Commit

Permalink
Merge pull request #468 from support-project/feature/upgrade_pdfbox
Browse files Browse the repository at this point in the history
Upgrade pdfbox for use japanese font
  • Loading branch information
koda-masaru authored Sep 15, 2016
2 parents 8adc093 + a88b8b2 commit 85fdee8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parsers</artifactId>
<version>1.12</version>
<version>1.13</version>
<exclusions>
<exclusion>
<groupId>org.ow2.asm</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<PDPage> pdPages = document.getDocumentCatalog().getAllPages();
int page = 0;
Expand All @@ -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) {
Expand All @@ -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);
}
Expand Down

0 comments on commit 85fdee8

Please sign in to comment.