Forum


Replies: 6   Views: 2089
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 blocked-ISSL  · 19-06-2019 - 15:53

Thanks for the reply. Indexer doesn't return any information about placeholders - just their raw data and fake file names, no sizes are included unfortunately. This is all that's returned when using Indexer:

array:2 [
        0 => array:2 [
                "content" => b"""
                        ëPNG\r\n
                        image code here
                        """
                "path" => "media/image1.png"
        ]
        1 => array:2 [
                "content" => b"""
                        ëPNG\r\n
                        image code here
                        """
                "path" => "media/image2.png"
        ]
]

I can't use the options of replacePlaceholderImage because I don't know the width or height of the placeholder as the templates are user-editable, and 'auto' uses the replacement size (which might be many times larger than the placeholder).

Using getDocxPathQueryInfo only returns the following:

array:2 [
  "length" => 1
  "query" => "//w:drawing[descendant::wp:docPr[contains(@descr, "$FLOORPLAN$")]]"
]

which I can't use

The drawingChildNodes comes from DOMXPath right? But the code requires a DOMDocument which I don't know how to create from a template.