Forum


Replies: 3   Views: 4982
Createpdfanddownload
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by SSystems  · 11-04-2013 - 12:12

I did this on TransformDoc.inc
[code]
/**
* Convert DOCX to PDF, using dompdf. DOCX->XHTML->PDF
*
* @access public
*/
public function generatePDF($isStream = false)
{
$this->generateXHTML();
$this->cleanXHTML();
try {
$domPDF = new DOMPDF();
$domPDF->load_html($this->_xhtml);
$domPDF->render();
$fileName = $this->getFileName() . '.pdf';
if(!$isStream)
{
$fp = fopen($fileName, "a");
fwrite($fp, $domPDF->output());
fclose($fp);
}
else{
$domPDF->stream($fileName);
}

}
catch (Exception $err) {
echo 'Unable to generate PDF file. ';
echo $err;
}
}[/code]