I use ZF2 and DOMPDFModule\View\Model\PdfModel to generate pdf. When it is shown as a view everything is fine, but I cannot find out how to save it to file (in the code, without asking user about download). I have code like this:
use DOMPDFModule\View\Model\PdfModel;
$viewModel = new PdfModel($variables);
$viewModel->setTemplate('pos/stocklist/' . $type);
$viewModel->setOption('paperSize', 'a4');
$viewModel->setOption('paperOrientation', 'portrait');
$viewModel->setOption('fileName', 'stock.pdf');
I tried to do it in this way, but render method does not exist:
$output = $viewModel->render();
$handle = fopen($file_path.DIRECTORY_SEPARATOR.$file_name , 'w');
fwrite( $handle,$output );
fclose( $handle );
Appreciate your help.