D
D
di8822102018-06-22 23:18:20
PHP
di882210, 2018-06-22 23:18:20

How to change the data in docx(word) and then convert to pdf and download the file?

The task is to substitute data into a docx document (from a web form), then convert this word document to pdf and download it to a computer - How to do it all?
I started digging in the direction of phpword - there is either something with the library or something with the server - it is not installed from the composer - I downloaded some ready-made one, it smelled only with lowering the php version to 5.6.
Found an example on the net:

$_doc = new \PhpOffice\PhpWord\TemplateProcessor('Template.docx');
$_doc->setValue('d_num', '10/29-77-Ю'); //номер договора
$_doc->setValue('d_date', '04.10.2014');
$_doc->setValue('last_name', 'тест5');
$_doc->setValue('name', 'тест 6');
$_doc->setValue('surname', 'тест 7');

$_doc->saveAs("dogovor0006.docx");

Saves to the server. But I don’t know how to further convert to pdf and download.
Downloaded the DomPDF library. I know how to convert html to pdf:
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("new_file.pdf");

how to convert to pdf docx?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question