0
I have the following code to generate a PDF file and I want to use file_get_contents to include a chart and table that are generated dynamically on another page but the result is not as expected.
Code with class mPDF:
<?php
#--> inclui class
include("mpdf.php");
#--> $mpdf=new mPDF('utf-8', 'A4-L');
#--> header
$mpdf->SetHTMLHeader('
<table width="100%" style="vertical-align: bottom; font-family: serif; font-size: 14pt; color: #000000; font-weight: bold; border-bottom:0.5mm solid #220044;">
<tr>
<td width="50%"><span style="font-weight: bold;">Titulo Header</span></td>
<td width="45%" style="text-align: right;"><span style="font-size: 9pt;">Subtitulo<br /></span></td>
<td width="5%" style="text-align: right;"><img src="imagens/img_logo.png" width="60" height="35" /></td>
</tr>
</table>
');
#--> page
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
$mpdf->AddPage('L'); // Adds a new page in Landscape orientation
$mpdf->WriteHTML('
<body style="background-gradient: linear #CCCCCC #FFFFFF 0 0.5 1 0.5;">
');
$mpdf->WriteHTML(file_get_contents('conteudo/pagina1.php'));
#--> footer
$mpdf->SetHTMLFooter('
<table width="100%" style="vertical-align: bottom; font-family: serif; font-size: 8pt; color: #000000; font-weight: bold; font-style: italic;">
<tr>
<td width="33%"><span style="font-weight: bold; font-style: italic;">Titulo Footer 1</span></td>
<td width="33%" align="center" style="font-weight: bold; font-style: italic;">{PAGENO}/{nbpg}</td>
<td width="33%" style="text-align: right; ">Titulo Footer 2</td>
</tr>
</table>
');
#-->
$mpdf->Output();
?>
The page code1.php
<?php
#--> errros
error_reporting(0);
#--> inclui conexao mysql
require_once('../../Connections/conn.php');
#--> inclui fusion charts
include('../../includes/FusionCharts/dynamic/DWFChart.inc.php');
#--> fusion chart # PDFGrafico9 data include
include('../../includes/FusionCharts/dynamic/data/fc_PDFGrafico9_data.php');
#--> consulta grafico
mysql_select_db($database_conn, $conn);
$query_Reporrt1Grf = "SELECT * FROM sys_report1";
$Reporrt1Grf = mysql_query($query_Reporrt1Grf, $conn) or die(mysql_error());
$row_Reporrt1Grf = mysql_fetch_assoc($Reporrt1Grf);
$totalRows_Reporrt1Grf = mysql_num_rows($Reporrt1Grf);
#--> consulta tabela
mysql_select_db($database_conn, $conn);
$query_Report1 = "SELECT * FROM sys_report1";
$Report1 = mysql_query($query_Report1, $conn) or die(mysql_error());
$row_Report1 = mysql_fetch_assoc($Report1);
$totalRows_Report1 = mysql_num_rows($Report1);
#--> fusion chart #PDFGrafico9 dynamic filter data
$dFCPDFGrafico9 = new DWFChart("PDFGrafico9", "MSStackedColumn2DLineDY", "../../includes/FusionCharts/charts/", 800, 400, "", "", "", "", "", "");
$dFCPDFGrafico9->setVersion("1.1.1");
$dFCPDFGrafico9->setConfigXML($PDFGrafico9_dataXML);
$dFCPDFGrafico9->setCategory($Reporrt1Grf, "col1", "", "");
$dFCPDFGrafico9->addSeries($Reporrt1Grf, "col2", "", "color='ff' seriesName='col2' renderAs='Column'", "Group 1", "");
$dFCPDFGrafico9->addSeries($Reporrt1Grf, "col6", "", "color='ff6600' seriesName='col6' renderAs='Column'", "Group 2", "");
$dFCPDFGrafico9->addSeries($Reporrt1Grf, "col4", "", "color='33ff00' seriesName='col4' renderAs='Line'", "Group 3", "");
$dFCPDFGrafico9->setOrdering('None', 'asc');
$dFCPDFGrafico9->prepareData();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../../css/stylo.css"/>
<title>Untitled Document</title>
<script type="text/javascript"
<src="../../includes/FusionCharts/dynamic/js/FusionCharts.js"></script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="50"> </td>
</tr>
<tr>
<td align="center" valign="middle">
<?php
// (FCChart Begin) #PDFGrafico9
renderFusionChart($dFCPDFGrafico9, 800, 400);
// #PDFGrafico9 (FCChart End)
?>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr class="tableHeader1a">
<td rowspan="2" class="tableHeader1d">col1</td>
<td height="25" colspan="4" class="tableHeader1d tableHeader1e">col A</td>
<td height="25" colspan="3" class="tableHeader1d tableHeader1e">col B</td>
<td rowspan="2">col9</td>
</tr>
<tr class="tableHeader1a">
<td height="25" class="tableHeader1c">col2</td>
<td height="25" class="tableHeader1c">col3</td>
<td height="25" class="tableHeader1c">col4</td>
<td height="25" class="tableHeader1d">col5</td>
<td height="25" class="tableHeader1c">col6</td>
<td height="25" class="tableHeader1c">col7</td>
<td height="25" class="tableHeader1d">col8</td>
</tr>
<?php do { ?>
<tr class="tableDesc1a" bgcolor="<?php echo ($ac_sw1++%2==0)?"#FFFFFF":"#EBEBEB"; ?>">
<td height="25" class="tableDesc1c"><?php echo $row_Report1['col1']; ?></td>
<td height="25" class="tableDesc1b"><?php echo $row_Report1['col2']; ?></td>
<td height="25" class="tableDesc1b"><?php echo $row_Report1['col3']; ?></td>
<td height="25" class="tableDesc1b"><?php echo $row_Report1['col4']; ?></td>
<td height="25" class="tableDesc1c"><?php echo $row_Report1['col5']; ?></td>
<td height="25" class="tableDesc1b"><?php echo $row_Report1['col6']; ?></td>
<td height="25" class="tableDesc1b"><?php echo $row_Report1['col7']; ?></td>
<td height="25" class="tableDesc1c"><?php echo $row_Report1['col8']; ?></td>
<td height="25"><?php echo $row_Report1['col9']; ?></td>
</tr>
<?php } while ($row_Report1 = mysql_fetch_assoc($Report1)); ?>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($Reporrt1Grf);
mysql_free_result($Report1);
?>
Any suggestions?
Thank you.
There is an error in the log ?
– Marabesi
No, no... :(
– user26858
Put the code you have in the page file1.php for ease
– Marabesi
I added page code 1 above.
– user26858
First thing, why is error_reporting set to 0? Second, can you generate this out of the lib ? Just using the script ?
– Marabesi
is just to suppress errors of some variables, in production gets 0, in test no use or comment... the normal page runs in the browser, with chart and table, just want to insert this fork and table in the writehtml of class mPDF.
– user26858