I work on docx uploaded by users and I want to add line numbering (like this: http://prntscr.com/n5rc1s) on the docx before exporting it in PDF.
I tried to add this with PhpOffice but I did not succeed.
My code can convert in PDF but without line numbering.
Thanks for your help :)
My code:
require_once('vendor/autoload.php');
define('PHPWORD_BASE_DIR', realpath(__DIR__));
$domPdfPath = realpath(PHPWORD_BASE_DIR . '/vendor/dompdf/dompdf');
\PhpOffice\PhpWord\Settings::setPdfRendererPath($domPdfPath);
\PhpOffice\PhpWord\Settings::setPdfRendererName('DomPDF');
$phpWord = new \PhpOffice\PhpWord\PhpWord();
//Open template and save it as docx
$document = $phpWord->loadTemplate('test.docx');
$document->saveAs('temp.docx');
//Load temp file
$phpWord = \PhpOffice\PhpWord\IOFactory::load('temp.docx');
$sections = $phpWord->getSections();
foreach ($sections as $section) {
$section->getStyle()->setLineNumbering(array());
}
//Save it
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
$xmlWriter->save('result.pdf');