Replies: 5   Views: 2294
Image got cropped and stretched
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 arlandi  · 08-09-2017 - 10:00

I'm trying to replace an image with replacePlaceholderImage. but the image got stretched and cropped instead of displaying correctly.

this is the code i'm using.

$docx = new CreateDocxFromTemplate("New_Foto_BA.docx");
$opsi_foto = array(
    "width" => 10

$opsi_text = array(

$data = "{\"type\":\"rear_camera\",\"value\":\"IMG_07092017_213225_PSBVaabhn2.jpg\"}";

if ($data===false)

$foto = json_decode($data, true);
   "FOTO_BA"=>" ", "KET_TAMBAHAN"=>"Lorem Ipsum dolor sit amet",
), $opsi_text); 

$docx->replacePlaceholderImage("FOTO_BA", $foto["value"], $opsi_foto);

$namaFile = "The_Result.docx";

$docx->createDocx( $namaFile );

echo "https://localhost/phpdocx/".$namaFile;


Posted by admin  · 08-09-2017 - 10:13


What version and license of phpdocx are you using?


Posted by arlandi  · 08-09-2017 - 10:27

i'm using the Basic license and version 7.

Posted by admin  · 08-09-2017 - 10:32


Your username doesn't have any license tied, please send to contact[at] the username or email of the user that has purchased the license.


Posted by arlandi  · 11-09-2017 - 09:34

Thank you

That works great!