Pregunta

Heyy ... Soy nuevo en PHP .. Estoy tratando de convertir una página que contenga tablas anidadas en PDF. Esta es la página que necesito para convertir

<!DOCTYPE html>
<html>
<body>

<div style="margin-left: auto; margin-right: auto; width: 75%">  
<table width="1000" border="1" bordercolor="#500000">
<tr>
<td colspan="2" style="background-color:#500000;">
<h1 style="text-align:center;"><font color="#FFFFFF">COMPANY NAME</font></h1>
<h2 style="text-align:center;"><font color="#FFFFFF">BALANCE SHEET</font></h2>
<h3 style="text-align:center;"><font color="#FFFFFF">DATE</font></h3>
</td>
</tr>
<tr>
<th width="50%">ASSETS</th>
<th width="50%">LIABILITIES</th>
</tr>
</tr>
<tr>
<!-- <td width="480"><?php include('assets.php') ?></td>       
<td width="480">fadffd</td> -->
<td><iframe src="assets.php" frameborder="0" width="500" height="500"></iframe></td>
<td><iframe src="liabilities.php" frameborder="0" width="500" height="500"></iframe></td></tr>
<tr>
<td colspan="2" style="background-color:#500000;text-align:center;"><font color="#FFFFFF">lkfjsdgjljsglhlhfsaj</font></td>
</tr>
</table>
</div>
</body>

</html>

Aquí he incluido dos tablas como datos de la tabla usando iframe. Cuando intento importarlo a PDF utilizando el código que se muestra a continuación, las tablas anidadas no se muestran.

<?php 
include("MPDF53/MPDF53/mpdf.php");
$mpdf=new mPDF('win-1252','A4','','',15,10,16,10,10,10);//A4 page in portrait for      landscape add -L.
$mpdf->SetHeader('|Your Header here|');
$mpdf->setFooter('{PAGENO}');// Giving page number to your footer.
$mpdf->useOnlyCoreFonts = true;    // false is default
$mpdf->SetDisplayMode('fullpage');
// Buffer the following html with PHP so we can store it to a variable later
ob_start();
?>
<?php include "balancesheet.php";
//This is your php page ?>
<?php 
$html = ob_get_contents();
ob_end_clean();
// send the captured HTML from the output buffer to the mPDF class for processing
$mpdf->WriteHTML($html);
//$mpdf->SetProtection(array(), 'user', 'password'); uncomment to protect your pdf page with password.
$mpdf->Output();
exit;
?>

por favor ayuda ...

¿Fue útil?

Solución

¿Está seguro de que desea usar MPDF?Hay varias otras opciones.Por ejemplo, DOMPDF es compatible con explícitamente las tablas complejas.Y puede ver algunas otras opciones en esta respuesta

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top