pdfminer.six icon indicating copy to clipboard operation
pdfminer.six copied to clipboard

Character and word spacing (Tc and Tw parameters) should also apply at end of strings

Open dhdaines opened this issue 7 months ago • 1 comments

The way character spacing (PDF 2.0 section 9.3.2) is applied is needlessly complex and also incorrect in pdfminer.six. Instead of applying spacing between the glyphs in a single text-showing operator, it should simply apply it to the glyph displacement, such that it "carries over" to the next text-showing operator.

For this PDF: character_spacing.pdf

pdfminer.six (in PDFTextDevice.render_string_horizontal) will currently do something like this:

Image

when it should do this:

Image

dhdaines avatar May 14 '25 04:05 dhdaines

(this is also true for word spacing but it appears that pdfminer.six does that correctly)

dhdaines avatar May 14 '25 05:05 dhdaines