I am working with the PhpWord library and the templateProcess.php file to generate documents based on templates, now it works correctly if I only add text.
However when wanting to add images the file is generated as corrupt.
Has anyone happened to you?
This fragment used to create find and replace images within the template.
$templateWord->cloneRow("equipo_nombre", $count_items);
for ($i=1; $i <= $cantidad_planes; $i++) {
$templateWord->setValue('equipo_nombre#'.$i, $data[0]->contenido[$i-1]['caracteristicas']['marca']['nombre_marca'] ." ". $data[0]->contenido[$i-1]['caracteristicas']['modelo']['nombre_modelo']);
$source = 'assets/media/productos/0cd36903c57479d99943d915710c20e6.jpg';
$templateWord->setImageValue('equipo_foto#'.$i, 'equipo_foto.png', $source);
}
$filename = 'cotizacion_'.date('YmdHms').'.docx';
$target_file = $_SERVER['DOCUMENT_ROOT'] . "/admin/assets/".$filename;
$templateWord->saveAs($target_file);
Thanks!