I'm generating pdf's on a web server with puppeteer in Chrome.
The problem: Font sizes differ slightly (2-5pixels depending on the font size) between my local Chrome (Mac) and Chromium being run inside the docker container (Linux). No other css attributes or the print @page margins seem to be affected, only the font-size is bigger in the docker container. The font is also being correctly embedded.
The pdf's I'm creating have to be pixel perfect (space is very limited), so this throws of the pagination... Any other ideas in addition to what I've tried already?
This is only half the solution for fixing the vertical size differences:
Set a numerical line-height (e.g. line-height: 1
) in the body (normal
is not enough), and then set line-heights to all other text elements.
This will work to keep the vertical heights identical for single line elements in local Chrome & docker Chromium. But if you have text flowing on multiple lines, the bigger font-size in docker Chromium can cause the text to take up additional rows. My bad workaround: make the font-size a bit smaller :(