I've used both PhantomJS and Wkhtmltopdf as binaries run with symfony/process in the application. Both are good, but Wkhtmltopdf handles fonts better from my experience.
There is a library available for Laravel which wraps the Wkhtmltopdf binaries (https://github.com/NitMedia/wkhtml2pdf), but I've had mixed success (it had a bug where anything logged to stderr was considered an error, rather than checking the exit code). It'd be worth giving it a go though.
I've also used wkhtmltopdf with a Laravel project with success. However, I did not use the Laravel package mentioned above. I ended up extending the core a bit so I could use View::pdf ()
and render the results of a view as a PDF document.
Internally this worked by saving the results of the view into a temporary HTML file whose path and name could be determined ahead of time. Then I used shell_exec
to pass the path of the temp HTML file to wkhtmltopdf. The output path is also predetermined in this process. After all of this I just used Response::download()
with the appropriate temp file name and headers.
Its not too difficult if you can control the file paths yourself and have access to reads and writes on the file system.
Hi,
thanks for your advice.
I have resolved this issue. I did not change any php code and configuration. I am using google fonts to fix the character problems.
Best Regards.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href='http://fonts.googleapis.com/css?family=Dosis&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
</head>
<body>
<p style="font-family: 'Dosis', sans-serif;">Abc def ghı ijk lmn oöp rsş tuü vyz</p>
<p style="font-family: 'Dosis', sans-serif;">ABC DEF GHI İJK LMN OÖP RSŞ TUÜ VYZ</p>
</body>
</html>
I have also created package that wraps Wkhtmltopdf: https://github.com/barryvdh/laravel-snappy (And one that wraps DomPDF with the same api: https://github.com/barryvdh/laravel-dompdf)
It's called laravel-snappy because it uses https://github.com/KnpLabs/snappy instead of accessing wkhtmltopdf directly (= more popular, better tested etc)
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community