Forum


Replies: 3   Views: 3311
Retrieve size of template image
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 milan.cvejic  · 29-11-2016 - 17:15

Hi,

i need to generate some charts and to insert them as image in Word document. Using chart functionality in word is no solution.

So I am asking is there any way to retrieve size of template images, so that I can generate propely sized charts?

Thanks,

Posted by milan.cvejic  · 30-11-2016 - 11:03

Thanks for reply but, using Indexer class I can retrieve content of images and retrieve physical size. I need dimensions of image in word file, as used images can be resized in word file.

Any idea on how to do this?

Thanks

Posted by admin  · 30-11-2016 - 12:19

Hello,

The current version of phpdocx don't include a method to get that information from Word. We have added a task to include support in the next release of phpdocx for the Indexer class.

Although it can't be done using a method from phpdocx using the current version of the library, it could be done parsing the XML manually:

The size of an image is set by two tags:

<wp:extent cx="914400" cy="914400"/> image size

<wp:effectExtent b="0" l="0" r="0" t="0"/> effects of the image

The cx and cy values are EMUs:

EMUs are used for coordinates in vector-based drawings and embedded pictures. The EMU is a virtual unit to bridge both centimeters and inches. One inch equates to 914400 EMUs and a centimeter is 360000.
(https://startbigthinksmall.wordpress.com/2010/01/04/points-inches-and-emus-measuring-units-in-office-open-xml/)

Regards.