Forum


Replies: 10   Views: 3021
Upgrade guide from version 5 corporate to 9 advanced
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 Bouillou  · 20-06-2019 - 06:27

Hello,

I will buy the upgrade from version 5 corporate to the version 9 advanced today. Is there any upgrade guide available? A list of depracated methods, ... to help me in this upgrading process?

Best regards,

Sébastien

Posted by admin  · 20-06-2019 - 06:57

Hello,

Don't worry, the same code that works with phpdocx 5 will work with phpdocx 9; maybe you just need to do some minor changes and two methods have been removed (enableCompatibilityMode that is not used anymore and the conversion to PDF using MS Word that has been moved to a new option of the conversion plugin). In most cases you just need to include/require CreateDocx.php instead of CreateDocx.inc to upgrade to the new version.

Anyway, if you have any question or doubt you can reply to this same topic or write to contact[at]phpdocx.com

Regards.

Posted by Bouillou  · 20-06-2019 - 11:10

Thank you, the upgrade has been successfully done (for a simple basic document generation from a template at least.)

The goal of this upgrade is to use the new method getWordStyles to retrieve the font size of the style Normal.

Discussed in topic : https://www.phpdocx.com/en/forum/default/topic/1771

So, I do :

$referenceNode = array(
    'type' => 'style',
    'contains' => 'Normal',
);
$normalStyleContents = $this->docx->getWordStyles($referenceNode);

But, I am just retriving a large multidimentional array containing a lot of data, but no font-size.

Can you help me to retrieve the font size of the Normal style please?

Best regards

 

Posted by admin  · 20-06-2019 - 11:37

Hello,

If the Normal style, that is the default style for paragraphs doesn't have a size value, then default document styles are used.

You can get the default styles from a DOCX using Indexer:

$indexer = new Indexer('document.docx');
$indexerOutput = $indexer->getOutput();

// default run-of-text styles
var_dump($indexerOutput['styles']['docDefaults']['rPrDefault']);
// default paragraph styles
var_dump($indexerOutput['styles']['docDefaults']['pPrDefault']);

You just need to get the w:sz value (the size value is usually found as default run-of-text style).

Regards.

Posted by Bouillou  · 20-06-2019 - 12:07

Ok, but Indexer constructor throw error on line 601:

xml_parse_into_struct($parserXML, $pPrDefaultTag->item(0)->firstChild->ownerDocument->saveXML($pPrDefaultTag->item(0)->firstChild), $values, $indexes);

Notice: Trying to get property 'ownerDocument' of non-object

What can I do?

Posted by admin  · 20-06-2019 - 12:17

Hello,

Is it a PHP error or a PHP notice? Please try ignoring PHP notices.

If you send the document to contact[at]phpdocx.com we'll check it. All w:pPrDefault tags should have at least one child.

Regards.

Posted by Bouillou  · 20-06-2019 - 12:21

Yes it is a "Notice", but I won't disable notice in developpement because of this. I will send you the template by mail in a minute.

Thanks for your support

Posted by admin  · 20-06-2019 - 12:26

Hello,

We asked to disable the PHP notices just to check if the styles are returned ignoring that notice; not as a definitive solution. We'll test your DOCX, maybe some additional check is needed.

Regards.

Posted by Bouillou  · 20-06-2019 - 12:30

Ok, but as the saveXML() by chaining on the NULL ownerDocument, the application throw a fatal error.

We will continue this discussion by mail.

Again, thanks for your support,

Sébastien

Posted by admin  · 20-06-2019 - 14:06

Hello,

Although we have sent a sample script by e-mail, this is the code used to get the font size when using getWordStyles to query a style element:

$referenceNode = array(
    'type' => 'style',
    'contains' => 'Normal',
);

$contents = $docx->getWordStyles($referenceNode);
$size = null;
foreach ($contents as $content) {
        foreach ($content['style']['styles'] as $style) {
                if ($style['tag'] == 'w:sz') {
                        $size = $style['attributes']['w:val'];
                }
        }
}

print_r('Size: ' . $size . PHP_EOL);

Half-points are used to specify font sizes.

Regards.

Posted by merrysmith5304@mail.com  · 01-08-2019 - 08:21

Deleted by admin · 01-08-2019 - 08:23