hi everyone, i've just started using phpdocx and i'm having some trouble getting everything to work.
i'm on PHP 8.2.11 and i'm using the latest premium version of phpdocx.
So i'm trying to start from a template then replace variables and then create a docx to finally convert it into pdf.
here's my code :
<?php
use Dompdf\Dompdf;
require_once '../Assets/phpdocx/14.5/classes/CreateDocx.php';
require_once '../Assets/phpdocx/14.5/classes/TransformDocAdvNative.php';
require_once '../Assets/DOMPDF/2.0.4/autoload.inc.php';
$V_docx = new CreateDocxFromTemplate('../Tmp/template.docx');
$V_variables = $V_docx->getTemplateVariables();
$V_article = $_POST['article'];
$V_designation = $_POST['designation'];
$V_signature = $_POST['signature'];
$V_arrayVariables = array($V_variables['document']['0'] => $V_article, $V_variables['document']['2'] => $V_designation, $V_variables['document']['4'] => $V_signature, $V_variables['document']['6'] => $V_signature);
$V_docx->replaceVariableByText($V_arrayVariables);
if (file_exists('../Tmp/genere/document.docx'))
{
unlink('../Tmp/genere/document.docx'); // Supprime le fichier existant
}
$V_dompdf = new Dompdf();
$V_options = $V_dompdf->getOptions();
$V_options->setDefaultFont('Courier');
$V_dompdf->setOptions($V_options);
$V_optionsTransform = array(
'dompdf' => $V_dompdf
);
phpinfo();
$V_docx->createDocx('../Tmp/genere/document');
$V_docx->transformDocument('../Tmp/genere/document.docx', '../Tmp/genere/document.pdf', 'native', $V_optionsTransform);
i'm using the native method to convert docx to pdf.
The thing is when i try to execute this code, i get a warning :
Warning: A non-numeric value encountered in *files*/phpdocx/14.5/classes/TransformDocAdvPDFPlugin.php on line 162
if anyone could enlighten me on what i've misunderstood or done wrong that would be great !
ty for reading
Tristan