title: how can I save PdfModel to file in Zend Framework 2?
body: <p>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:</p>
  
  <pre><code>use DOMPDFModule\View\Model\PdfModel;
  
  $viewModel = new PdfModel($variables);
  $viewModel-&gt;setTemplate('pos/stocklist/' . $type);
  $viewModel-&gt;setOption('paperSize', 'a4');
  $viewModel-&gt;setOption('paperOrientation', 'portrait');
  $viewModel-&gt;setOption('fileName', 'stock.pdf');
  </code></pre>
  
  <p>I tried to do it in this way, but render method does not exist:</p>
  
  <pre><code>$output = $viewModel-&gt;render();
  $handle = fopen($file_path.DIRECTORY_SEPARATOR.$file_name , 'w');
  fwrite( $handle,$output );
  fclose( $handle );
  </code></pre>
  
  <p>Appreciate your help.</p>