Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert docx to pdf using PHP

Tags:

php

I am currently generating multiple .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?

like image 869
Keith Avatar asked Feb 15 '12 18:02

Keith


1 Answers

Open the generated docx 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();

Also, you can export the docx to PDF with

    $docx->generatePDF();

Note this is not a free library

like image 105
Juanma Avatar answered Oct 22 '22 14:10

Juanma