modesty / pdf2json

converts binary PDF to JSON and text, for server-side PDF processing and command-line use.
https://github.com/modesty/pdf2json
Other
1.98k stars 378 forks source link

pdf2json interprets one word as 2 JSON objects #71

Open felixhaag opened 8 years ago

felixhaag commented 8 years ago

Hi,

I use pdf2json to parse some pdfs, which contain week-tables. However, after I parse the files, there’s a strange behavior - some of the words are separated in the JSON-file as different objects, while they’re actually one word inside of the pdf.

Example: Files: plan.pdf plan.txt (sorry, can't upload JSON-Files)

The word: „Champignons“ (column: „Mittwoch“, row: 2, line: 3) is interpreted as "Champig" and "nons" (2 JSON Objects)

JSON: {"x":26.51,"y":16.388,"w":3.932,"sw":0.35678125,"clr":0,"A":"left","R":[{"T":"Champig","S":3,"TS":[0,12,0,0]}]},{"x":28.745,"y":16.388,"w":7.169,"sw":0.35678125,"clr":0,"A":"left","R":[{"T":"nons%20und%20Lauch%20","S":3,"TS":[0,12,0,0]}]}

This issue also occur in other rows. I suspect that it's caused by the specific pdf-structure.

Any ideas how I can fix that?

Thanks for your support!

modesty commented 8 years ago

have you tried to parse with '-m' in cmd line?

felixhaag commented 8 years ago

Thanks for your reply! Tried it with '-m' in command-line, but the words are still interpreted as separated JSON-objects

modesty commented 8 years ago

could you remove Math.abs from line 197 of lib/pdf2json/pdffont.js, then run with -m again?

felixhaag commented 8 years ago

After I removed the Math.abs function and ran it with the 'm' parameter, the strings in the columns next to each other were merged together. The affected words are still presented in separated JSON-objects.

modesty commented 8 years ago

could you try it with v1.1.6?

autoantwort commented 4 years ago

Hello, I don't think that this is a bug with pdf2json and the word Champignons is divided into two PDF objects in the PDF. So this is a "Bug" when the document was created. If you select the text with the chromium buildin PDF Viewer the word Champignons gets splitted into two words too.

image