News
Creating a PDF document using PHPDocX
- Jun 06, 2011
Warning
This post is outdated. For up date information about creating PDF documents please refer to the Conversion plugin tutorial documentation.
PHPdocx can create PDF documents creating first the docx and then transform it to PDF.
You only need to add the transform at the end of the document like this:
// You need to call also TransformDoc.inc to create a PDF
require_once '../../classes/TransformDoc.inc';
require_once '../../classes/CreateDocx.inc';
$docx = new CreateDocx();
$text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' .
'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ' .
'enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut' .
'aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit ' .
'in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ' .
'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui ' .
'officia deserunt mollit anim id est laborum.';
$paramsText = array(
'b' => 'single',
'font' => 'Arial'
);
$docx->addText($text, $paramsText);
$docx->createDocx('example_mixed');
// Creating the PDF
$document = new TransformDoc();
$document->setStrFile('example_mixed.docx');
$document->generatePDF();