简体   繁体   中英

Java - PDFBox - Text Extraction

I have been using pdfbox for extracting text information from PDFs. I have succesfully parsed all properties of text such as fontname , fontface , size ,position etc.

PROBLEM: I am using pdfbox1.2.1(latest version). The getCharacter() in TextPosition class returns the full string except the last character. The last character is parsed as a separate string.

Ex: "How are you" is parsed as "How are yo" and "u" (2 separate strings).

I dont want it to happen that way..

Has anybody come accross this? .. Am i doing something wrong??.. Waiting for reply..

Thanks and Regards, Magggi

This issue is solved.

The following code in processEncodedText( byte[] string ) in PDFStreamEngine.java

if( spacingText == 0 && (i + codeLength) < (string.length - 1) )
{
    continue;
}

should be changed to

if( spacingText == 0 && (i + codeLength) < (string.length) )
{
    continue;
}

Regards, Maggi

Yes. This issue is solved by pdfbox.
Try latest version of pdfbox. The latest version can be downloaded from http://pdfbox.apache.org/download.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM