Forum


Replies: 5   Views: 2304
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;
?>

 

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

Hello

What version and license of phpdocx are you using?

Regards.

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

Hello,

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

Regards.

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

Thank you

That works great!