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
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
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.
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
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.
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?
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.
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
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.
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
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.