Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- File document = new File(strFile_path);
- Parser parser = new AutoDetectParser();
- //PDFParser parser = new PDFParser();
- ContentHandler handler = new BodyContentHandler(Integer.MAX_VALUE);
- Metadata metadata = new Metadata();
- PDFParserConfig config = new PDFParserConfig();
- // 太字などを文字を重ねることで表現している場合における重複文字を無視するかどうか
- config.setSuppressDuplicateOverlappingText(true);
- // テキスト下線などを無視するかどうか
- config.setExtractAnnotationText(false);
- ParseContext context = new ParseContext();
- context.set(PDFParserConfig.class, new PDFParserConfig());
- try {
- // 構文を解析するプログラムをパーサ呼ぶが、それを実行。
- parser.parse(new FileInputStream(document), handler, metadata, new ParseContext());
- }
- catch (FileNotFoundException e) {
- :
- }
- :
- catch (Exception e) {
- }
- // PDFの文章を表示
- System.out.println("handler :[" + handler.toString() + "]");
- context.set(PDFParserConfig.class, new PDFParserConfig());
- context.set(PDFParserConfig.class, config);
- try {
- // 構文を解析するプログラムをパーサ呼ぶが、それを実行。
- parser.parse(new FileInputStream(document), handler, metadata, new ParseContext());
- try {
- // 構文を解析するプログラムをパーサ呼ぶが、それを実行。
- parser.parse(new FileInputStream(document), handler, metadata, context);
Add Comment
Please, Sign In to add comment