use custom fonts with wkhtmltopdf

Since it is a Google Web font you need not to write @font-face in you style sheet just use following link tag in your source code: <link href=”http://fonts.googleapis.com/css?family=Jolly+Lodger” rel=”stylesheet” type=”text/css”> and <style type = “text/css”> p { font-family: ‘Jolly Lodger’, cursive; } </style> will work. By the way, in your code you are defining @font-face … Read more

wkhtmltopdf with full page background

wkhtmltopdf v 0.11.0 rc2 What ended up working: wkhtmltopdf –margin-top 0 –margin-bottom 0 –margin-left 0 –margin-right 0 <url> <output> shortens to wkhtmltopdf -T 0 -B 0 -L 0 -R 0 <url> <output> Using html from stdin (Note dash) echo “<h1>Testing Some Html</h2>” | wkhtmltopdf -T 0 -B 0 -L 0 -R 0 – <output> Using … Read more

How to install wkhtmltopdf with patched qt?

This straightforward solution (no need to install xvfb, neither compiling QT neither wkhtmltopdf) works like a charm on my Debian Jessie server : cd mytmpfolder wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz sudo tar xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz sudo mv wkhtmltox/bin/wkhtmlto* /usr/bin/ #create simple html test file echo “<html><body>test</body></html>” >> test.html #perform conversion sudo wkhtmltopdf –disable-smart-shrinking –lowquality –enable-external-links –enable-internal-links test.html test.pdf

How do I get WKHTMLTOPDF to execute via PHP?

You can also try my project here. It provides a clean OO interface to the command line utility: https://github.com/mikehaertl/phpwkhtmltopdf Usage is very simple: <?php use mikehaertl\wkhtmlto\Pdf; $pdf = new Pdf; // Add a HTML file, a HTML string or a page from a URL $pdf->addPage(‘/home/joe/page.html’); $pdf->addPage(‘<html>….</html>’); $pdf->addPage(‘http://google.com’); // Add a cover (same sources as above … Read more

WkHTMLtoPDF not loading local CSS and images

In my case – wkhtmltopdf version 0.12.2.1 (with patched qt) – adding a base tag to the head section with the absolute path made sure images and css did get loaded. <html> <head> … <base href=”http://www.example.com/”> <link href=”http://stackoverflow.com/assets/css/style.css” rel=”stylesheet”> … </head>

How can I use footers and headers with wkhtmltopdf?

Wkhtmltopdf does support even very complex headers and footers. wkhtmltopdf.exe -T 50mm –header-html www.google.com www.stackoverflow.com test.pdf && test.pdf That command uses the page at www.google.com as a 50mm header for www.stackoverflow.com for every page. Note: If you use a custom page for the header/footer, you need to add <!DOCTYPE HTML> in the beginning of your … Read more