Character positions in PDF output are rounded to int, causing inconsistent spacing #3260

Open
DmitryFromDubna opened this Issue Dec 22, 2016 · 10 comments

Projects

None yet

4 participants

@DmitryFromDubna

Hello,
I can see the issue on Windows and CentOS 6.7, but not on Ubuntu 14.04. See attached screnshots:
A test file converted on Ubuntu vs same file converted on CentOS:
wkhtmltopdf ubuntu-vs-centos
Note that Ubuntu file has floating point coordinates, while Centos has all integers.
wkhtmltopdf ubuntu-vs-centos rounding
This is the test file:
Testme.html.zip

Both systems had msttcorefonts installed for a closer comparison, but obviously it is not specific to particular fonts.

I am getting pretty much the same result on Windows, although with different scaling; I only attach Ubuntu and CentOS because they are more apples-to-apples.

Tested using wkhtmltopdf 0.12.4.

@DmitryFromDubna

I suspect it is Qt issue actually, but I wonder if it is known? It should be affecting everyone, but I don't see any relevant reports.

@ashkulz
Member
ashkulz commented Dec 22, 2016

Was the same binary used? Then it is really strange and definitely a bug in Qt.

@DmitryFromDubna

Yes, same binary from wkhtmltox-0.12.4_linux-generic-amd64.tar.xz

@DmitryFromDubna

Just in case, here are the PDFs:
Testme.wkhtmltopdf.opt.centos.pdf
Testme.wkhtmltopdf.opt.ubuntu.pdf
I used this line to produce them, on both platforms:
wkhtmltopdf --disable-javascript --disable-local-file-access --page-height 279.39999999999998 --page-width 215.89999999999998 -L 12.699999999999999 -T 12.699999999999999 -R 12.699999999999999 -B 12.699999999999999 Testme.html Testme.wkhtmltopdf.opt.pdf

@mikerockett

Yeah, definitely noticed kerning issues on Windows. With some fonts, it doesn't appear to be a problem. With others, it is. Have not yet tried on centos, especially considering that my production server is cloudlinux.

@crystalfp
crystalfp commented Dec 26, 2016 edited

On Windows, if the <body> contains no font-family CSS, then the spacing between letters is horribly messed up. Instead if I add body {font-family: Arial,san-serif;} CSS rule, it renders perfectly. Instead of Arial, Calibri is also OK. It works also with serif fonts. I tried just with Garamond.
Hope it helps.
mario

@DmitryFromDubna

Hi @crystalfp, this does not seem to work for me. Would you mind correcting my test file Testme.html.zip and attaching here?

@DmitryFromDubna

Additional info: same error exists in conversion to SVG, but conversion to PNG works perfectly (tested on RHEL):
comparepdfsvgpng
Attached SVG and PNG outputs in Testme.png.svg.zip

@crystalfp

It happens also with your test file.
Testme.pdf
Thanks for looking at it!
mario

@crystalfp

Win 7, wkhtmltopdf version: Windows (MSVC) 0.12.4 64-bit

It happens also with your test file.
Testme.pdf
Thanks for looking at it!
mario

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment