Write HTML in PDF with TCPDF

From SimIT Wiki

Jump to: navigation, search

1. Make sure you have latest PHPJasperXML (0.7 or above) 2. Prepare sample source code as below <?php
include_once('class/tcpdf/tcpdf.php'); //1st changes for tcpdf
include_once("class/PHPJasperXML.inc");
include_once ('setting.php'); //content user,password and host setting
$xml = simplexml_load_file("sample5.jrxml");
$id=$_GET['id']; //parameter
$PHPJasperXML = new PHPJasperXML("en","TCPDF"); //2nd changes for tcpdf
$PHPJasperXML->debugsql=false;
$PHPJasperXML->arrayParameter=array("id"=>$id);
$PHPJasperXML->xml_dismantle($xml);
$PHPJasperXML->transferDBtoArray($server,$user,$pass,$db);
$PHPJasperXML->outpage("I"); //page output method I:standard output D:Download file

?>
3. Open properties window for text field which contain HTML text (You can combine variable, field inside the text field)
4. Add new property "writeHTML" with value "1" (Fill in both without double quote)
5. Render the report you will found it work! (You can refer sample 5 from sample project)

Personal tools