Fixes to PDF article
This commit is contained in:
parent
c29601db41
commit
9332eb5210
18
pdf/pom.xml
18
pdf/pom.xml
|
@ -24,49 +24,31 @@
|
||||||
<version>3.8.1</version>
|
<version>3.8.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.pdfbox</groupId>
|
|
||||||
<artifactId>pdfbox</artifactId>
|
|
||||||
<version>2.0.3</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox-tools -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.pdfbox</groupId>
|
<groupId>org.apache.pdfbox</groupId>
|
||||||
<artifactId>pdfbox-tools</artifactId>
|
<artifactId>pdfbox-tools</artifactId>
|
||||||
<version>2.0.3</version>
|
<version>2.0.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/net.sf.cssbox/pdf2dom -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.sf.cssbox</groupId>
|
<groupId>net.sf.cssbox</groupId>
|
||||||
<artifactId>pdf2dom</artifactId>
|
<artifactId>pdf2dom</artifactId>
|
||||||
<version>1.6</version>
|
<version>1.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.itextpdf</groupId>
|
<groupId>com.itextpdf</groupId>
|
||||||
<artifactId>itextpdf</artifactId>
|
<artifactId>itextpdf</artifactId>
|
||||||
<version>5.5.10</version>
|
<version>5.5.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi</artifactId>
|
<artifactId>poi</artifactId>
|
||||||
<version>3.15</version>
|
<version>3.15</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.poi</groupId>
|
|
||||||
<artifactId>poi-ooxml</artifactId>
|
|
||||||
<version>3.15</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-scratchpad -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-scratchpad</artifactId>
|
<artifactId>poi-scratchpad</artifactId>
|
||||||
<version>3.15</version>
|
<version>3.15</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/batik-transcoder -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.xmlgraphics</groupId>
|
<groupId>org.apache.xmlgraphics</groupId>
|
||||||
<artifactId>batik-transcoder</artifactId>
|
<artifactId>batik-transcoder</artifactId>
|
||||||
|
|
|
@ -23,7 +23,6 @@ public class PDF2HTMLExample {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void generateHTMLFromPDF(String filename) throws ParserConfigurationException, IOException {
|
private static void generateHTMLFromPDF(String filename) throws ParserConfigurationException, IOException {
|
||||||
try {
|
|
||||||
PDDocument pdf = PDDocument.load(new File(filename));
|
PDDocument pdf = PDDocument.load(new File(filename));
|
||||||
PDFDomTree parser = new PDFDomTree();
|
PDFDomTree parser = new PDFDomTree();
|
||||||
Writer output = new PrintWriter("src/output/pdf.html", "utf-8");
|
Writer output = new PrintWriter("src/output/pdf.html", "utf-8");
|
||||||
|
@ -32,8 +31,5 @@ public class PDF2HTMLExample {
|
||||||
if (pdf != null) {
|
if (pdf != null) {
|
||||||
pdf.close();
|
pdf.close();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ public class PDF2TextExample {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void generateTxtFromPDF(String filename) throws IOException {
|
private static void generateTxtFromPDF(String filename) throws IOException {
|
||||||
try {
|
|
||||||
File f = new File(filename);
|
File f = new File(filename);
|
||||||
String parsedText;
|
String parsedText;
|
||||||
PDFParser parser = new PDFParser(new RandomAccessFile(f, "r"));
|
PDFParser parser = new PDFParser(new RandomAccessFile(f, "r"));
|
||||||
|
@ -44,9 +43,6 @@ public class PDF2TextExample {
|
||||||
PrintWriter pw = new PrintWriter("src/output/pdf.txt");
|
PrintWriter pw = new PrintWriter("src/output/pdf.txt");
|
||||||
pw.print(parsedText);
|
pw.print(parsedText);
|
||||||
pw.close();
|
pw.close();
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue