Exemplo n.º 1
0
 /**
  * @param string $file
  */
 public function save($file)
 {
     $cmd = $this->_detectWkhtmltopdf();
     $cmd .= " " . $this->_generateSize();
     $cmd .= " " . $this->_generateMargin();
     $cmd .= " --encoding " . $this->_page['encoding'];
     $pdfs = array();
     foreach ($this->_html as $i => $page) {
         $f = '/tmp/' . Athem_Utils::randString(10);
         file_put_contents("{$f}.html", $page);
         $ncmd = "{$cmd} file://{$f}.html {$f}.pdf";
         exec($ncmd, $output, $result);
         $pdfs[] = "{$f}.pdf";
         if (!empty($result)) {
             throw new Athem_Pdf_FromHtml_Exception('Error while processing pdf page ' . $i . "\n {$ncmd} \n" . implode("\n<br />", $output), Athem_Pdf_FromHtml_Exception::ERR_OS_BINARY_ERROR);
         }
         unlink("{$f}.html");
     }
     if (count($pdfs) == 1) {
         copy($pdfs[0], $file);
         unlink($pdfs[0]);
     } else {
         $pdfMerge = Athem_Pdf_Merge_Abstract::factory($this->_page['merge'], $pdfs);
         $pdfMerge->save($file);
     }
 }
Exemplo n.º 2
-2
 public function save($file)
 {
     $pdfs = array();
     foreach ($this->_html as $i => $page) {
         $f = '/tmp/' . Athem_Utils::randString(10);
         $pdf = new HTML2PDF($this->_getOrientation(), $this->_getSize(), 'en');
         $pdf->WriteHTML($page);
         $pdf->Output("{$f}.pdf", 'F');
         $pdfs[] = "{$f}.pdf";
     }
     $pdfMerge = Athem_Pdf_Merge_Abstract::factory($this->_page['merge'], $pdfs);
     $pdfMerge->save($file);
 }