将RTL doc转换为PDF

时间:2018-07-12 04:15:37

标签: php right-to-left phpword

有什么方法可以读取RTL doc / docx文件并转换为具有相同样式的PDF格式?代码的结果只是文档的一部分,没有图像,页眉和页脚部分。

// Creating the new document...
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$phpWord = \PhpOffice\PhpWord\IOFactory::load('doc2.docx');

$lang    = new \PhpOffice\PhpWord\Style\Language();
$lang->setLangId(1065);
$phpWord->getSettings()->setThemeFontLang($lang);

// Adding Text element with font customized using explicitly created font style
$fontStyle = new \PhpOffice\PhpWord\Style\Font();
$fontStyle->setBold(true);
$fontStyle->setRTL(true);
$fontStyle->setName('B nazanin');
$fontStyle->setSize(13);
$phpWord->addFontStyle('*', $fontStyle);

// I plan to get PDF version after converting HTML
// but it does not read all content from the word file

$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
$objWriter->save('doc.html');

0 个答案:

没有答案