I am currently creating several .docx files using PHPWord. I need to find a way to combine these docx files and save them as 1 pdf file. Is there a way that this can be done?
Open the generated document with PHPDOCX http://www.phpdocx.com/
require_once 'phpdocx_pro/classes/TransformDoc.inc'; $docx = new TransformDoc(); $docx->setStrFile('document.docx'); $docx->generateXHTML(); $html = $docx->getStrXHTML();
In addition, you can export the document to PDF with
$docx->generatePDF();
Please note that this is not a free library.
You can look at http://www.phplivedocx.org/ , they support docx and also generate PDF files through the zend framework.
Humm I use this: https://github.com/benskay/PHP-Digital-Format-Convert-Epub-Mobi-PDF/tree/master/library/phpDocx and that:
require_once dirname(__FILE__) .'/phpdocx/classes/TransformDoc.inc.php'; require_once dirname(__FILE__) .'/phpdocx/classes/CreateDocx.inc.php'; $docx = new TransformDoc(); $docx->setStrFile('document.docx'); $docx->generatePDF();
==> This seems to work, but ... where is the generated PDF file? How can I get a pdf file?
/** * return the pdf stream as a string returned from the function */ function output($debug = false) { ... }
so just write the result of "generatePDF ()" to the file.
eg:
$content = $docx->generatePDF(); $myfile = fopen("newfile.pdf", "w"); fwrite($myfile, $content); fclose($myfile);