Forum


Replies: 4   Views: 2015
Thai and japanese fonts
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by jeremie  · 01-04-2020 - 17:08

So I tested transformDocument with an embedded font. It works fine when using "replaceVariableByText" but it doesn't work when using "replaceVariableByHTML".

In the code below, "Template.docx" is a template with embedded font and only one variable named $hello$ in the template. The embedded font is not installed in our Linux server.

Here is a code that works:

$docx = new CreateDocxFromTemplate('Template.docx');
$docx->replaceVariableByText(array('hello' => 'Hello world'));
$docx->createDocx('TestTransformDocument.docx');
$docx->transformDocument('TestTransformDocument.docx', 'TestTransformDocument.pdf', 'libreoffice');

And here is a code that doesn't work:

$docx = new CreateDocxFromTemplate('Template.docx');
$docx->replaceVariableByHTML('hello', 'block', 'Hello world');
$docx->createDocx('TestTransformDocument.docx');
$docx->transformDocument('TestTransformDocument.docx', 'TestTransformDocument.pdf', 'libreoffice');

In the first case, with "replaceVariableByText", we get a document with the text 'Hello world' in the embedded font (even though the font is not installed in our server).

In the first case, with "replaceVariableByHTML", we get a document with the text 'Hello world' in another default font, which is not the embedded font.

What are we doing wrong?