Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.6.0
-
None
Description
Follow the steps:
1. Download the example pdf I'll attach. It's the same as "example rich text format" pdf from idealsoftware.com but with text extraction protection disabled.
2a. java -jar pdfbox-app-1.6.0.jar ExtractText -sort rtf.pdf extr.txt
Actual results:
Text is all gibberish. If you look at it very carefully, sorting "reads" the text vertically and you find first characters of each line first, then second characters of each line, etc.
Moreover, on jdk7: java.lang.IllegalArgumentException: Comparison method violates its general contract! (that's the text position sorting comparator)
Poking around the code indicates that sorting is correct if character rotation was 270 degrees. It (correctly?) calculates it as zero instead.
2b. java -jar pdfbox-app-1.6.0.jar ExtractText rtf.pdf extr.txt
Actual results:
Text is fine, but each page is glued to a single line. Poking around the code indicates that character offsets go down correctly, but expected line height is huge (full page height or width?) and therefore they never go down sufficiently to trigger a newline detection.
So, there's something very wrong with character positions in those files, making pdfbox not extract text correctly.