|
22 | 22 | use DOMNode;
|
23 | 23 | use DOMXPath;
|
24 | 24 | use Exception;
|
| 25 | +use PhpOffice\Common\Drawing; |
25 | 26 | use PhpOffice\PhpWord\Element\AbstractContainer;
|
26 | 27 | use PhpOffice\PhpWord\Element\Row;
|
27 | 28 | use PhpOffice\PhpWord\Element\Table;
|
@@ -902,15 +903,35 @@ protected static function parseImage($node, $element)
|
902 | 903 | break;
|
903 | 904 | case 'width':
|
904 | 905 | $width = $attribute->value;
|
| 906 | + |
| 907 | + // pt |
| 908 | + if (false !== strpos($width, 'pt')) { |
| 909 | + $height = Drawing::pointsToPixels((float) str_replace('pt', '', $width)); |
| 910 | + } |
| 911 | + |
| 912 | + // px |
| 913 | + if (false !== strpos($width, 'px')) { |
| 914 | + $width = str_replace('px', '', $width); |
| 915 | + } |
| 916 | + |
905 | 917 | $style['width'] = $width;
|
906 | 918 | $style['unit'] = \PhpOffice\PhpWord\Style\Image::UNIT_PX;
|
907 |
| - |
908 | 919 | break;
|
909 | 920 | case 'height':
|
910 | 921 | $height = $attribute->value;
|
| 922 | + |
| 923 | + // pt |
| 924 | + if (false !== strpos($height, 'pt')) { |
| 925 | + $height = Drawing::pointsToPixels((float) str_replace('pt', '', $height)); |
| 926 | + } |
| 927 | + |
| 928 | + // px |
| 929 | + if (false !== strpos($height, 'px')) { |
| 930 | + $height = str_replace('px', '', $height); |
| 931 | + } |
| 932 | + |
911 | 933 | $style['height'] = $height;
|
912 | 934 | $style['unit'] = \PhpOffice\PhpWord\Style\Image::UNIT_PX;
|
913 |
| - |
914 | 935 | break;
|
915 | 936 | case 'style':
|
916 | 937 | $styleattr = explode(';', $attribute->value);
|
|
0 commit comments