Forum


Replies: 5   Views: 2516
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.

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

$opsi_text = array(
    "parseLineBreaks"=>true,
);

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

if ($data===false)
{
    exit(0);
}

$foto = json_decode($data, true);
$docx->replaceVariableByText(array(
   "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;
?>