I made the following simple laravel artisan command:
Artisan::command('test:pdf',function(){
\PhpOffice\PhpWord\Settings::setPdfRendererName(\PhpOffice\PhpWord\Settings::PDF_RENDERER_DOMPDF);
\PhpOffice\PhpWord\Settings::setPdfRendererPath('.');
$tmpFile = storage_path().'/contracts/test.docx';
$outfile = storage_path().'/contracts/test.pdf';
$phpWord = \PhpOffice\PhpWord\IOFactory::load($tmpFile);
$phpWord->save($outfile,'PDF');
});
It receives a docx file and converts it into pdf. But for an ackward reason the docx contains greek letters and once rendered in pdf are converted into ????
.
So any ideas how I can save a pdf file from a docx respecting UTF-8 characters?
My Answer:
> Greek letters are replaced with ??? once I convert a docx into pdf using PHPWord because the default font used by PHPWord may not support Greek characters. To fix this issue, you can try specifying a font that supports Greek characters in your PHPWord document before converting it to PDF. You can do this by setting the font for the specific text containing Greek letters using PHPWord's font styling options. Additionally, you can also try using a different PDF renderer or library that supports Greek characters.
Rate this post
4 of 5 based on 6260 votesComments