Open eflister opened 3 years ago
Thank you for the bug report. There is a fuzzy logic that inserts missing spaces (and also newlines): https://github.com/Yuras/pdf-toolbox/blob/f1d20479fe6782bc293468ac05186e658216388b/document/lib/Pdf/Document/Page.hs#L293 You can get the actual glyphs using this function: https://github.com/Yuras/pdf-toolbox/blob/f1d20479fe6782bc293468ac05186e658216388b/document/lib/Pdf/Document/Page.hs#L205, but you'll have to deal with missing spaces instead :) The reason for the but seems to be failure to parse a font. I'll take a closer look later this week (I hope)
So I checked the file. It uses the standard fonts, they don't include char widths. So we extract glyphs with incorrect bounding box. To fix it we need to include AFM files (like there) and parse them to get widths for the standard fonts. I'll try to find time for that, but it'd be faster if someone will take care of it.
thanks for looking into it! it's not urgent for me, i have other solutions, but great to know the cause :)
i'm reading data out of a 3 column table in some pdf weekly covid reports. it usually works fine, but in two out of ~30 pdf's,
pdf-toolbox
has started sprinkling spaces into a few of the numbers apparently randomly. here's an example: randomspaces.pdfthe table covers the final few pages of the pdf. it lists zip codes in numerical order. most come out fine, but here's some code that prints out the lines with the extra spaces. i contrast it with
pdftotext
, a binding topoppler
. both it and the command linepdftotext
that comes withpoppler
show the correct output without spaces.output: