I'm pretty new to laravel and I'm currently having some difficulties with documents. my problem as follows:
I have .docx document that I modify using \PhpOffice\PhpWord\TemplateProcessor, after that I need to convert the resulted document to a pdf file in order to display it on my view.
I tried Mpdf but I noticed that it doesnt work with docx :
public function topdf($bill){
$Mpdf = new Mpdf();
$sourceFile = storage_path( $bill);
$pageCount = $Mpdf->SetSourceFile($sourceFile);
for ($i = 1; $i <= ($pageCount); $i++) {
$Mpdf->AddPage();
$import_page = $Mpdf->ImportPage($i);
$Mpdf->UseTemplate($import_page);
$Mpdf->WriteText(75, 73.3, 'hello');
}
$file_name = 'app/public/' . Str::random(18) . '.pdf';
$Mpdf->Output(storage_path($file_name),Destination::DOWNLOAD);
} If $bill is a file.docx this doesn't work, but if it's a file.pdf it imports it to another new pdf.
I'm stucking in this problem it's been a while. Any help please
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire