I've read many, many topics about the hassle with multiple font-styles/faces when using wkhtmltopdf.
We are currently experiencing problems when using Nunito (provided by Google webfonts) in regular style and bold style on the same page. We have tried many (possible) solutions, but none of them has given us a solution yet.
We tried the following solutions, but no one succeeded yet:
- Change the font family name using FontForge
- Convert the fonts using fontsquirrel
- Manually convert fonts to base64 using openssl (mac)
- Convert to base64 http://www.opinionatedgeek.com/dotnet/tools/base64encode/default.aspx
- Using remote includes for fonts (from google webfont)
- Change the fonts to SVG
All the above methods did not work. The browser does render it correctly, but wkhtmltopdf seems to be rendering it different.
We have published a few testcase's on: http://bannes.nl/fonts
If anyone has a suggestion on how to fix this, please let me know. In case you are using mac and have installed wkhtmltopdf, please feel free to test the cases on http://bannes.nl/fonts. I have included the output PDF for every testcase in their directory.
Hope someone has got a suggestion on how to fix this!
Best regards,
Robin
2 Answers
Answers 1
- Use this similar utility, backed by more developers: https://github.com/plessl/wkpdf
- if that does not work for you, check that you have the latest version of
wkhtmltopdf
If the above does not work at all, you may try a different command line utility, or a robust solution like: "LaTeX": https://www.latex-project.org/
Answers 2
Why not change lib ?
I used wkhtmltopdf but I found the inner peace with TCPDF
I printed an HTML page doing this
// set font $pdf->SetFont('itclegacysansltmedium', '', 12); // add a page $pdf->AddPage(); // set some text to print ob_start(); include('view.php'); $html = ob_get_clean(); $pdf->writeHTML($html, true, false, true, false, '');
0 comments:
Post a Comment