Please, include your name, height in centimeters and weight in kilograms:
<?php require_once '[path to Docxpresso]/CreateDocument.inc'; $doc = new Docxpresso\createDocument(array('template' => './ideal-weight.odt')); $format = '.'.$_POST["file"];//.pdf, .doc, .docx, .odt, .rtf //replace single variable $imc = calcIMC($_POST["height"],$_POST["weight"]); $arr_XY = calcXYIcon($_POST["height"],$_POST["weight"]); $doc->replace(array( 'name' => array('value' => $_POST["name"]), 'height' => array('value' => $_POST["height"]), 'weight' => array('value' => $_POST["weight"]), 'BMI' => array('value' => number_format($imc,2)) )); $doc->replace(array('img_person' => array('value' => nameImgBody($imc,$_POST["sex"]), 'image' => true))); $doc->replace(array('head' => array('value' => ''.nameImgHead($imc,$_POST["sex"]), 'offsetX' => ''.$arr_XY['x'].'px', 'offsetY' => ''.$arr_XY['y'].'px', 'image' => true))); $rnd = rand(1,999999); $str_file = 'tmp/imc' . $rnd . $format; $doc->render('./'.$str_file); sleep(1); while(!file_exists('./'.$str_file)) sleep(1); echo "{url: '".$_SERVER['HTTP_REFERER'].$str_file."'}"; /* Auxiliary functions to compute the BMI and pick the right image to render */ function getYCuadratic($x) { $x -=22; $y = ($x*$x)/450; return $y; } function calcIMC($h,$w) { $h = intval($h)/100; $h2=$h*$h; $imc=intval($w)/$h2; return $imc; } function calcXYIcon($h,$w) { $arr['x'] = 0; $arr['y'] = 0; $x = 160 - 40; $x = intval((intval($w)-40)*490/$x); $arr['x']=$x+10; $y = 200 - 150; $y = intval((200-intval($h))*380/$y); $arr['y'] = $y+35; return $arr; } function idImgBody($imc) { $n=1; if($imc<18.5) $n=2; else if($imc<18.5) $n=3; else if($imc<25) $n=4; else if($imc<30) $n=5; else if($imc<35) $n=6; else if($imc<40) $n=6; else if($imc>=40) $n=6; return $n; } function nameImgBody($imc,$woman) { $n = idImgBody($imc); $src = './img/dibu0'.$n.''.($woman=='woman'?'w':'').'.png'; return $src; } function nameImgHead($imc,$woman) { $n = idImgBody($imc); $src = './img/cabeza0'.$n.''.($woman=='woman'?'w':'').'.png'; return $src; }