Replies: 6   Views: 195
Get the image size of an image placeholder when using createdocxfromtemplate
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 ISSL  · 19-06-2019 - 13:30

The only topic I can find related to this is but the information there doesn't work.

I am loading a document using CreateDocxFromTemplate, and there is a placeholder image in there with a placeholder of $FLOORPLAN$. I need to do is get its width, because I can't just use replacePlaceholderImage as it will squash the image (the floor plans are different sizes), and I can't set the width as I don't know the width of the placeholder image (it changes between templates).

I thought this would work looking at Indexer.php, but it requires DOMDocument and I can't see a way to create that from CreateDocxFromTemplate.

// load XML content
$contentDOM = new DOMDocument();
$contentDOM->loadXML($xml); # How do I do this with CreateDocxFromTemplate??

// do a xpath query getting only image tags
$contentXpath = new DOMXPath($contentDOM);
$contentXpath->registerNamespace('rel', '');
$imageEntries = $contentXpath->query('//rel:Relationship[@Type=""]');

How do I simply get the width of a placeholder image?