Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to upgrade to using org.apache.pdfbox 2.0
- Loading branch information
1 parent
d7c84c6
commit cbe6ded
Showing
4 changed files
with
60 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
|
||
import org.apache.pdfbox.io.RandomAccessFile; | ||
import org.apache.pdfbox.pdfparser.PDFParser; | ||
import org.apache.pdfbox.pdmodel.PDDocument; | ||
import org.apache.pdfbox.text.PDFTextStripper; | ||
|
||
|
||
|
||
public class test { | ||
|
||
public static void main(String[] args) { | ||
String string = null; | ||
try { | ||
PDFParser pdfParser = new PDFParser(new RandomAccessFile(new File("./samples/bus.pdf"), "r")); | ||
pdfParser.parse(); | ||
PDDocument pdDocument = new PDDocument(pdfParser.getDocument()); | ||
PDFTextStripper pdfTextStripper = new PDFLayoutTextStripper(); | ||
string = pdfTextStripper.getText(pdDocument); | ||
} catch (FileNotFoundException e) { | ||
e.printStackTrace(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
}; | ||
System.out.println(string); | ||
} | ||
|
||
} |