word to pdf converter php code example

Example: phpword word to pdf

//DomPDF 
<?php
// Require composer autoloder.
require __DIR__.'/vendor/autoload.php';

use PhpOffice\PhpWord\IOFactory;
use PhpOffice\PhpWord\Settings;

// Make sure you have `dompdf/dompdf` in your composer dependencies.
Settings::setPdfRendererName(Settings::PDF_RENDERER_DOMPDF);
// Any writable directory here. It will be ignored.
Settings::setPdfRendererPath('.');

$phpWord = IOFactory::load('dok.docx', 'Word2007');
$phpWord->save('document.pdf', 'PDF');

Tags:

Misc Example