Jomon Antony Jomon Antony - 1 month ago 7x
PHP Question

How to write Dom pdf output to file in Zf2

I am using dompdf to create one pdf file in zf2.

$pdf = new PdfModel();
$pdf->setOption('filename', 'monthly-report'); // Triggers PDF download, automatically appends ".pdf"
$pdf->setOption('paperSize', 'a4'); // Defaults to "8x11"
$pdf->setOption('paperOrientation', 'landscape'); // Defaults to "portrait"

// To set view variables
'message' => 'Hello'

return $pdf;

Like this. But I want to write my pdf to a file.


Try This

$pdfView = new ViewModel();
            'fetchResult'   => $fetchResult,
    $html = $this->getServiceLocator()->get('viewpdfrenderer')->getHtmlRenderer()->render($pdfView);
    $eng = $this->getServiceLocator()->get('viewpdfrenderer')->getEngine();

    $pdfCode = $eng->output();