Created
September 24, 2018 15:09
-
-
Save abcprintf/f3600c180f586033eb48e7470a74b32a to your computer and use it in GitHub Desktop.
how to convert .docx to .pdf [PHPword]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$rendererLibraryPath = PHPWORD_BASE_DIR . '/vendor/dompdf/dompdf'; | |
\PhpOffice\PhpWord\Settings::setPdfRendererPath($rendererLibraryPath); | |
\PhpOffice\PhpWord\Settings::setPdfRendererName('DomPDF'); | |
$phpWord = new \PhpOffice\PhpWord\PhpWord(); | |
//Load temp file | |
$phpWord = \PhpOffice\PhpWord\IOFactory::load('.docx'); | |
//Save it | |
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF'); | |
$xmlWriter->save('xx.pdf'); | |
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'HTML'); | |
$xmlWriter->save('xx.html'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment