iText: missing characters when converting PDF to Text

本秂侑毒 提交于 2019-12-25 16:54:20

问题


I am Trying to extract the text from the this pdf using the LocationTextExtractionStrategy.class, but for some reason a number of characters are being dropped during the parsing.

On the first page of the original .pdf;

    【表紙】
    【提出書類】有価証券報告書
    【根拠条文】金融商品取引法第24条第1項
    【提出先】近畿財務局長
    【提出日】平成22年6月28日
    【事業年度】第27期(自 平成21年4月1日 至 平成22年3月31日)
    【会社名】株式会社カネミツ
    【英訳名】KANEMITSU CORPORATION

Resulting text output has numbers such as 22,28 and the english text "KANEMATSU" missing;

    【表紙】
    【提出書類】 有価証券報告書
    【根拠条文】 金融商品取引法第条第1項
    【提出先】 近畿財務局長
    【提出日】 平成年6月日
    【事業年度】 第期(自 平成年4月1日 至 平成年3月日)
    【会社名】 株式会社カネミツ
    【英訳名】

Here's the code...

    PdfReader reader = new PdfReader(sourceFileUrl);
    String strategyClass =         “com.itextpdf.text.pdf.parser.LocationTextExtractionStrategy.class”

    int n = reader.getNumberOfPages();
    for(int I = 1; I < n; i++) {
    TextExtractionStrategy strategy = (TextExtractionStrategy) Class.forName(strategyClass).newInstance();
            String text = PdfTextExtractor.getTextFromPage(reader, i,strategy);
    …
    }

I have reviewed other questions of a similar nature on SO, this page is similar although i am able to copy the text from the pdf directly so this is probably a different issue.

来源:https://stackoverflow.com/questions/29254678/itext-missing-characters-when-converting-pdf-to-text

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!