wkhtmltopdf / wkhtmltopdf

Convert HTML to PDF using Webkit (QtWebKit)
https://wkhtmltopdf.org
GNU Lesser General Public License v3.0
13.99k stars 1.83k forks source link

crash with Floating point exception when bootstrap CSS is referenced #4752

Open hsalazarl opened 4 years ago

hsalazarl commented 4 years ago

wkhtmltopdf version(s) affected: 0.12.6 (with patched qt)

OS information Linux Mint 20

Description Trying to generate a PDF that includes CSS from bootstrap causes a floating point exception. Current output is: Loading pages (1/6) Floating point exception (core dumped) ] 42%

How to reproduce Including the following in a HTML page causes the issue:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

Then running: wkhtmltopdf --enable-local-file-access /path/to/html.html /home/user/out.pdf

or even trying to generate the PDF from the bootstrap page itself: wkhtmltopdf https://getbootstrap.com/docs/4.4/getting-started/introduction/ /home/user/out.pdf

Expected behavior Should generate a PDF including bootstrap CSS and/or fonts.

faustmann commented 4 years ago

I have the same issue at Ubuntu 18.04.5.

lucasrueda commented 4 years ago

Same issue at Ubuntu 20.04

lucasrueda commented 4 years ago

It fails with this exact line:

font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";

This line is inside the body css body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 1rem; font-weight: 400; line-height: 1.5; color: #212529; text-align: left; background-color: #fff; }

If you remove it, everything works like a charm!

Another approach is to leave only one font-family.. like this:

font-family: "Helvetica Neue";

faustmann commented 4 years ago

Thanks for pointing out the exact cause. :)

PhilterPaper commented 4 years ago

Does either omitting -apple-system or enclosing it in quotes "-apple-system" have any benefit? I'm wondering if processing is getting confused by the leading "-" and thinking it's a number.

lucasrueda commented 4 years ago

I thought the same as you.. but I tried with two font families (eg. Roboto and Arial) and it didn't work.