Ejemplo n.º 1
14
 /**
  * Save PhpWord to file
  *
  * @param string $filename Name of the file to save as
  */
 public function save($filename = null)
 {
     $fileHandle = parent::prepareForSave($filename);
     //  PDF settings
     $paperSize = 'A4';
     $orientation = 'P';
     // Create PDF
     $pdf = new \TCPDF($orientation, 'pt', $paperSize);
     $pdf->setFontSubsetting(false);
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->addPage();
     $pdf->setFont($this->getFont());
     $pdf->writeHTML($this->getContent());
     // Write document properties
     $phpWord = $this->getPhpWord();
     $docProps = $phpWord->getDocumentProperties();
     $pdf->setTitle($docProps->getTitle());
     $pdf->setAuthor($docProps->getCreator());
     $pdf->setSubject($docProps->getSubject());
     $pdf->setKeywords($docProps->getKeywords());
     $pdf->setCreator($docProps->getCreator());
     //  Write to file
     fwrite($fileHandle, $pdf->output($filename, 'S'));
     parent::restoreStateAfterSave($fileHandle);
 }
 /**
  * Save PhpWord to file.
  *
  * @param string $filename Name of the file to save as
  * @return void
  */
 public function save($filename = null)
 {
     $fileHandle = parent::prepareForSave($filename);
     //  PDF settings
     $paperSize = 'A4';
     $orientation = 'portrait';
     //  Create PDF
     $pdf = new \DOMPDF();
     $pdf->set_paper(strtolower($paperSize), $orientation);
     $pdf->load_html($this->getContent());
     $pdf->render();
     //  Write to file
     fwrite($fileHandle, $pdf->output());
     parent::restoreStateAfterSave($fileHandle);
 }
Ejemplo n.º 3
0
 /**
  * Save PhpWord to file
  *
  * @param string $pFilename Name of the file to save as
  * @throws  Exception
  */
 public function save($pFilename = null)
 {
     $fileHandle = parent::prepareForSave($pFilename);
     //  Default PDF paper size
     $paperSize = 'A4';
     $orientation = 'P';
     $printPaperSize = 9;
     if (isset(self::$paperSizes[$printPaperSize])) {
         $paperSize = self::$paperSizes[$printPaperSize];
     }
     $orientation = $orientation == 'L' ? 'landscape' : 'portrait';
     //  Create PDF
     $pdf = new \DOMPDF();
     $pdf->set_paper(strtolower($paperSize), $orientation);
     $pdf->load_html($this->writeDocument());
     $pdf->render();
     //  Write to file
     fwrite($fileHandle, $pdf->output());
     parent::restoreStateAfterSave($fileHandle);
 }
Ejemplo n.º 4
0
 /**
  * Save PhpWord to file.
  *
  * @param string $filename Name of the file to save as
  * @return void
  */
 public function save($filename = null)
 {
     $fileHandle = parent::prepareForSave($filename);
     //  PDF settings
     $paperSize = strtoupper('A4');
     $orientation = strtoupper('portrait');
     //  Create PDF
     $pdf = new \mpdf();
     $pdf->_setPageSize($paperSize, $orientation);
     $pdf->addPage($orientation);
     // Write document properties
     $phpWord = $this->getPhpWord();
     $docProps = $phpWord->getDocInfo();
     $pdf->setTitle($docProps->getTitle());
     $pdf->setAuthor($docProps->getCreator());
     $pdf->setSubject($docProps->getSubject());
     $pdf->setKeywords($docProps->getKeywords());
     $pdf->setCreator($docProps->getCreator());
     $pdf->writeHTML($this->getContent());
     //  Write to file
     fwrite($fileHandle, $pdf->output($filename, 'S'));
     parent::restoreStateAfterSave($fileHandle);
 }