Monthly archives: May, 2019

Create/generate PDF file in Silverstripe via Dompdf

install dompdf first: composer require dompdf/dompdf in Silverstripe controller: use Dompdf\Dompdf; use SilverStripe\Control\Email\Email; $pdfHtml = $memberapplication->renderWith(‘PDF/NewMemberPdf’); exit($pdfHtml); // uncomment for pdf debug $dompdf = newDompdf(); $dompdf->loadHtml($pdfHtml); $dompdf->setPaper(‘A4’, ‘portrait’); $dompdf->render(); //$dompdf->stream(); $pdfData = $dompdf->output(); $pdfFilename = ‘pdf/NewMemberPdf-‘.$memberapplication->ID.’.pdf’; file_put_contents($pdfFilename,$pdfData); // will save to public/pdf folder PDF/NewMemberPdf.ss in the SilverStripe templates folder usingĀ $memberapplication object’s variables send an email …