hello, im getting ??? symbols after convert docx to pdf file any ideas how to fix it?
any specifics? Can you post a code sample?
see screnshots 

actualy word file contains georgian alphabets and only that alphabets converted to ??? in pdf file, see word file screenshot

and finaly this is pdf file

OK, but that's probably because the font you are using in the PDF does not support UTF-8.
Understand. How can i use another font before convert to pdf?
I'm not to familiar with the PDF libraries, but you can set the font on $xmlWriter->setFont('arial');
Also, did you try with other PDF libraries (mpdf or dompdf)?
@moxetiale I'm very sory for the offtop, but what is your Atom color scheme called?
@troosan no i did not try other libraries, i will try setFont thanks
@autaut03 One dark
I have same problem. My .docx file:
Witam,
na imi臋 mam ${variableName} i jestem z Bia艂ogardu.
.pdf file:
Witam,
na imi? mam Jacek i jestem z Bia?ogardu.
And my php code:
require_once LIBRARY_PATH.'/bootstrap.php';
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$domPdfPath = realpath(VENDOR_PATH.'/dompdf/dompdf');
\PhpOffice\PhpWord\Settings::setPdfRendererPath($domPdfPath);
\PhpOffice\PhpWord\Settings::setPdfRendererName('DomPDF');
$template = new \PhpOffice\PhpWord\TemplateProcessor(FILES_PATH.'/imie.docx');
$template->setValue('variableName', 'Jacek');
$template->saveAs(FILES_PATH.'/result.docx');
//Load temp file
$phpWord = \PhpOffice\PhpWord\IOFactory::load(FILES_PATH.'/result.docx');
//Save it
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
$xmlWriter->save(FILES_PATH.'/result.pdf');
Any suggestions?
@troosan I have tried the dompdf, the same reasult. I will try $xmlWriter->setFont('arial') later.
$xmlWriter->setFont('arial') - dont work
This is working:
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$domPdfPath = realpath(VENDOR_PATH.'/dompdf/dompdf');
\PhpOffice\PhpWord\Settings::setPdfRendererPath($domPdfPath);
\PhpOffice\PhpWord\Settings::setPdfRendererName('DomPDF');
$template = new \PhpOffice\PhpWord\TemplateProcessor(FILES_PATH.'/imie.docx');
$template->setValue('variableName', 'Jacek');
$template->saveAs(FILES_PATH.'/result.docx');
//Load temp file
$phpWord = \PhpOffice\PhpWord\IOFactory::load(FILES_PATH.'/result.docx');
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
$objWriter->save(FILES_PATH.'/hello.html');
chmod(FILES_PATH.'/hello.html', 0777);
$dompdf = new \Dompdf\Dompdf();
$dompdf->load_html(file_get_contents(FILES_PATH.'/hello.html'));
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');
// Render the HTML as PDF
$dompdf->render();
$pdf_string = $dompdf->output();
file_put_contents(FILES_PATH.'/result2.pdf', $pdf_string);
And in file: phpwordsrcPhpWordWriterHTMLPartHead.php
$content .= '<head>' . PHP_EOL;
$content .= '<meta charset="UTF-8" />' . PHP_EOL;
$content .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>' . PHP_EOL;
$content .= '<title>' . $title . '</title>' . PHP_EOL;
// foreach ($propertiesMapping as $key => $value) {
// $value = ($value == '') ? $key : $value;
// $method = 'get' . $key;
// if ($docProps->$method() != '') {
// $content .= '<meta name="' . $value . '"'
// . ' content="' . (Settings::isOutputEscapingEnabled() ? $this->escaper->escapeHtmlAttr($docProps->$method()) : $docProps->$method()) . '"'
// . ' />' . PHP_EOL;
// }
// }
//$content .= $this->writeStyles();
$content .= '<style>body {font-family: DejaVu Sans, sans-serif}</style>' . PHP_EOL;
$content .= '</head>' . PHP_EOL;
@jkurowski When composer update or composer install, phpwordsrcPhpWordWriterHTMLPartHead.php - will change.
_Better:_
$fontStyle = new \PhpOffice\PhpWord\Style\Font();
$fontStyle->setName('DejaVu Sans, sans-serif');
Do you have a solution for the same problem?
Most helpful comment
@moxetiale I'm very sory for the offtop, but what is your Atom color scheme called?