Forum


Replies: 3   Views: 174
Using getwordstyles with a type
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  · 17-07-2024 - 09:24

Thank you for your response. You're right, the examples work perfectly. They helped me pintpoint the issue more accurately.

It's the "contains" option that doesn't work properly.

In example \examples\DocxPath\getWordStyles\sample_1.php, changing "contains" from 'level 2 heading' to 'simple Word' returns an empty array, although 'simple Word' is indeed contained in the second line of document \examples\files\DOCXPathTemplate.docx.

In other words, you can't find the string 'simple Word' with the following code:

require_once '../../../classes/CreateDocx.php';

$docx = new CreateDocxFromTemplate('../../files/DOCXPathTemplate.docx');

$docx = new CreateDocxFromTemplate($document_word);
$referenceNode = array(
    'type' => 'paragraph',
    'contains' => 'simple Word',
);
$styles = $docx->getWordStyles($referenceNode);

I think it's a bug because it used to work properly in previous versions.

Let me know if it's not a bug and I will gladly pay for additional technical support.