Forum


Replies: 1   Views: 2582
Problem with encoding of docx document
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 legaltrek  · 05-07-2017 - 14:02

Hello,

I have problem with some of the symbols from the German alphabet and they visualise broken in the DOCX. I tried to fix it with

$docx->setEncodeUTF8()

but it didn't work because the text already had UTF 8 encoding.

For example when I try to add Straße in docx looks like Straße. Can you help me, my code is like this 

....

$valuesTable = array(); 

$valuesTable[] =

array(
     array(
         "value" => "Straße"
      )

);

$paramsTable = array(
     'border'         => 'none',
     'tableAlign'     => 'center',
     'textProperties' => array('fontSize' => 10),
      'tableWidth'     => array('type' => 'pct', 'value' => 100)

);

$docx->addTable($valuesTable, $paramsTable);

....

I will be very grateful.

Regards

Posted by admin  · 05-07-2017 - 14:20

Hello,

phpdocx supports all charsets as MS Word does. We have tested your code and all characters appear fine when opening the DOCX.

If the strings are already UTF-8 you don't need to encode them again using setEncodeUTF8 (or you'll get a wrong string). Please check that the extension mbstring (http://php.net/manual/en/mbstring.installation.php) is installed and enabled and try again. Also check that the font family you are using supports that character.

If you still have the issue after installing mbstring, please send to contact[at]phpdocx.com the most simple script and the output DOCX that illustrates the issue and we'll run it and send back the DOCX generated on our servers.

Regards.