Forum


Replies: 3   Views: 1081
Pstyle is not adapted correctly randomly
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 Robin  · 24-08-2021 - 08:10

Hello,

I have often noticed that sometimes the pStyle is not adopted correctly when generating a DOCx. Sometimes the numbering of the pStyle is simply missing (e.g. header 1 - https://pasteboard.co/Khl9zkE.png). It really happens very randomly, then you just have to generate the DOCx again and then it works. Is this a known bug or is it something else?

With regards!

Posted by admin  · 24-08-2021 - 08:27

Hello,

What version and license of phpdocx are you using?

There's no known bug when working with custom styles and the pStyle option is fully tested and working. Maybe the correct style name is not being applied. We'd need to check the code you are running to know what method you are using and some DOCX file with that style that is not being applied correctly. If you are using an old version of phpdocx please check the documentation available on https://www.phpdocx.com/news/post/important-changes-for-lists-in-the-last-ms-word-update/221.

Regards.

Posted by Robin  · 24-08-2021 - 14:14

I am using the latest phpdocx trial version.

As already mentioned, it happens very randomly. Sometimes I have to execute the script multiple times with the same docx and then it works. 

$docx->addText($string, array('pStyle' => 'berschrift1'));

 

Posted by admin  · 24-08-2021 - 14:42

Hello,

As explained in our previous reply, the pStyle option is fully tested and working. We have done a quick test generating 200 DOCX outputs using addText with a custom paragraph style and in all cases the output is correct (the custom paragraph style is being applied correctly). Please test and run the included samples using the trial package.

We'd need to check the exact script you are running and the DOCX output you get when the style is not being applied: if you are using a template, importing styles, creating styles from scratch... Sorry but the trial package doesn't include this kind of support.

We are sure that the problem comes from some error in the code you are running (or your server is caching some content when generating the documents). For further support, if you purchase a license, please send an email to contact[at]phpdocx.com with a DOCX output that illustrates your issue and we'll be able to help you.

Regards.