Question

I'd like to create a PDF File on the server side. What's the best way to do this? Does anyone know a good solution?

Thank you in advance

Was it helpful?

Solution 2

There's a SilverStripe wrapper for DOMPDF, which should be just what you're after:

https://github.com/burnbright/silverstripe-dompdf

OTHER TIPS

There is also silverstripe-tcpdf:

https://github.com/mparkhill/silverstripe-tcpdf

This module is also findable if you search for PDF on the addons site :-)

http://addons.silverstripe.org/add-ons?search=pdf

I know that's an quite old question and already answered but I've also used Dompdf for a long time and it has a lot of limitations, like floating and css support.

Cause of that I wrote an module for wkhtmltopdf. Wkhtmltopdf uses a webkit render engine so that you'll have full css3 support.

If you want to have no limitations you could use this module

Small excerpt:

Create PDFs in SilverStripe with the power of WKhtmlTOpdf

This module adds the possibility to simply create PDFs from every DataObject you have. Based on WKhtmlTOpdf and mikehaertl's php wrapper.

Note this resource is too large to incorporate fully here.

There is a TCPDF module...

https://github.com/mparkhill/silverstripe-tcpdf

Else just add TCPDF to your composer.json with...

"require": {
    ...
    "tecnick.com/tcpdf": "6.0.013",
    ...
},

and review it's many examples to get going...

http://www.tcpdf.org/examples.php

or this one small snippet to render with a template...

$pdf = new TCPDF();
$pdf->AddPage();
$vd = new ViewableData();
$str = $vd->customise(ArrayData::create(array('MyVariable'=>'MyValue')))->renderWith('MyTemplateName');
$pdf->writeHTMLCell(0, 0, '', '', $str, 0, 1, 0, true, '', true);
$strContent = $pdf->Output(BASE_PATH.'/tmp/tmp.pdf', 'S');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top