Converting Html To Pdf Via Php (install Font For Html2pdf)
Solution 1:
Yes, you should use DOMPDF instead of other libraries. There are lots of fonts available. You can see at "dompdf/lib/fonts/dompdf_font_family_cache.dist.php" and choose according to your requirements. For change the font you need to change the def("DOMPDF_DEFAULT_FONT", "serif") at file path "dompdf/dompdf_config.inc.php":
You can download the latest version available of DOMPDF from: https://code.google.com/p/dompdf/downloads/detail?name=dompdf_0-6-0_beta3.tar.gz&can=2&q=
See the below example:
require_once("dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($htmlContent);
$dompdf->render();
$fileName = "invoice.pdf";
$dompdf->stream($fileName);//DOWNLOAD PDF //GET OUTPUT AS STRING AND PUT IN TO SOME FILE $output = $dompdf->output();
file_put_contents($fileName, $output);
Solution 2:
Try to use DomPdf instead of html2pdf. It works great for me on creating invoices in PDF. But some treatments (positioning and font sizes) in your CSS code are needed. The screen content placed as it is didn't work as i expected. https://github.com/dompdf/dompdf
Solution 3:
It's a bit of a hack, but I found the best way for me was to call capturejs using exec:
$run = "capturejs -u ";
$run .= "https://www.example.com/";
$run .= " -p tlsv1 -V ";
$run .= "1024x768";
$run .= " -o 'myimage.png'";
exec($run);
Post a Comment for "Converting Html To Pdf Via Php (install Font For Html2pdf)"