PHPOffice / PHPWord

A pure PHP library for reading and writing word processing documents
https://phpoffice.github.io/PHPWord/
Other
7.27k stars 2.69k forks source link

How to convert Cyrillic characters to PDF file in PhpWord? #1465

Open Sirgalas opened 6 years ago

Sirgalas commented 6 years ago

This is:

тест get тест

Current Behavior

get in place тест get ???? question that I do not so

Failure Information

When you open a docx file edited before Templateprocessor error occurs with Russian characters and both when converting to PDF and just when saving to DOCX

How to Reproduce

$phpWord = \PhpOffice\PhpWord\IOFactory::load($fileName);
        $lang = new Language();
        $lang->setLangId(1049);
        $phpWord->getSettings()->setThemeFontLang($lang);
        Settings::setPdfRendererPath(dirname(__DIR__).'/../vendor/dompdf/dompdf');
        Settings::setPdfRendererName('DomPDF');
        $writer = IOFactory::createWriter($phpWord,'PDF');
        header('Content-Disposition:attachment;filename="downloaded.pdf"');
        $writer->save('php://output');
    enter code here

Context

Sirgalas commented 6 years ago

As a result, as I understood the problem was in DomPDF switched to pdf Russian characters are displayed. But the question why docs is formed also remained open

evgenmedia commented 5 years ago

Is there any solution to this problem?

jukuan commented 4 years ago

Faced with that too

laxity7 commented 3 years ago

The easiest way is to use the "DejaVu Sans" font.


$phpWord = IOFactory::load($path);
$phpWord->setDefaultFontName('DejaVu Sans');