I am creating .docx files from a template using PHPWord. It works fine but now I want to convert the generated file to PDF.
.docx
PHPWord
PDF
Fi
You're trying to unlink the PDF file before saving it, and you have also to unlink the DOCX document, not the PDF one.
Try this.
$pdfWriter = \PhpOffice\PhpWord\IOFactory::createWriter($wordPdf , 'PDF'); $pdfWriter->save($filename.".pdf"); unlink($wordPdf);