Again, relying on google translate.  Y, I would think that suppressing 
overlapping characters should solve this problem.  Try pure PDFBox, and if the 
problem is there, try asking on the PDFBox list.


いきなりですが、表記件についてご質問させてください。

Javaで、Apache Tikaで、PDFのパース処理をしています。
ほとんどのPDFは、正常に、読み込めるのですが、パースエラーになったり、
パースできても、本文内の文字が連続する現象発生します。

ここで、お聞きしたいのは、「本文内の文字が連続する現象」の原因と対策方法です。
パースで取り出した長文の中から同じようなパターンの一部を下記へ抜粋。

⇒ 「(1)(1)(1)(1)風風風風林火林火林火林火山山山山用用用用DBDBDBDB」

おそらく、PDFの「(1)風林火山用DB」が書かれている部分をTikaが
取り出したときに、
PDFのコメント?、アクセシビリティ?、何かしら、普通に開いた時には見えないが、
PDFに埋め込まれているもの?をTikaがパースで取り出したのでは?と考えています。(想像)

ソース:
-----------------------------------------------------
File document = new File("/usr/local/sample.pdf"); Parser parser = new 
AutoDetectParser(); ContentHandler handler = new 
BodyContentHandler(Integer.MAX_VALUE);
Metadata metadata = new Metadata();
parser.parse(new FileInputStream(document), handler, metadata
                                                                         , new 
ParseContext()); String plainText = handler.toString(); 
System.out.println(plainText);
-----------------------------------------------------

原因は何で、対応策(Tikaへの設定?など)は、ありますでしょうか?



また、上記でだめでしたので、
どうやら、文字が連続する場所は、太字やアンダーバーがあるので、
下記のソースへ改造しましたが、結果が全く変わりません。
何か、お気づきの問題点などや解決策はありますでしょうか?

ソース:
-----------------------------------------------------
File document = new File("/usr/local/sample.pdf"); PDFParser parser = new 
PDFParser(); PDFParserConfig config = new PDFParserConfig();

// 太字などを文字を重ねることで表現している場合における重複文字を無視す
るかどうか = 無視したい
config.setSuppressDuplicateOverlappingText(true);

// テキスト下線などを無視するかどうか = 無視したい
config.setExtractAnnotationText(false);

parser.parse(new FileInputStream(document), handler, metadata, new 
ParseContext());

String plainText = handler.toString();
System.out.println(plainText);
-----------------------------------------------------


Tika初心者

Reply via email to