I am trying to create a dynamic PDF file from a PHP page and this gives me this error:
Fatal error: throw exception "Dompdf \ Exception" with the message "The line number 4 was not found, please report a problem in the tray HTML code 'in C: \ xampp \ htdocs \ Gokujou \ dompdf \ src \ Cellmap.php: 417 Trace stack: # 0 C: \ XAMPP \ HTDOCS \ Gokujou \ DOMPDF \ SRC \ FrameReflower \ TableRow.php (62): DOMPDF \ Cellmap-> get_frame_height (Object (DOMPDF \ FrameDecorator \ TableRow)) # 1 C: \ xampp \ htd \ Gokujou \ dompdf \ src \ FrameDecorator \ AbstractFrameDecorator.php (893): Dompdf \ FrameReflower \ TableRow-> reflow (NULL) # 2 C: \ XAMPP \ HTDOCS \ Gokujou \ DOMPDF \ SRC \ FrameReflower \ TableRowGroup. : Dompdf \ FrameDecorator \ AbstractFrameDecorator-> reflow () # 3 C: \ XAMPP \ HTDOCS \ Gokujou \ DOMPDF \ SRC \ FrameDecorator \ AbstractFrameDecorator.php (893): Dompdf \ FrameReflower \ TableRowGroup-> reflow (NULL)\ XAMPP \ HTDOCS \ Gokujou \ DOMPDF \ SRC \ FrameReflower \ Table.php (488): Dompdf \ FrameDecorator \ AbstractFrameDecorator-> reflow () # 5 C: \ XAMPP \ HTDOCS \ Gokujou \ DOMPDF \ SRC \ FrameDecorator (893): DOMPDF \ FrameReflower \ Table-> Reflow (Object (DOMPDF \ FrameDecorator \ Block)) in C: \ xampp \ htdocs \ Gokujou \ dompdf \ src \ Cellmap.php on line 417
I have a button on which he clicks "checkout", it will create a PDF page using this code:
<?php
require_once 'dompdf/autoload.inc.php';
use Dompdf\Dompdf;
$dompdf = new Dompdf();
$dompdf->loadHTML(file_get_contents('receipt.php'));
$dompdf->setPaper('A4', 'landscape');
$dompdf->render();
$dompdf->stream('samplepdf1');
?>
What is inside the receipt.php file:
<?php
include 'config.php';
?>
<!DOCTYPE html>
<html>
<head>
<title>Gokujou Japanese Restaurant</title>
<link rel="stylesheet" type="text/css" href="CSS/receipt.css">
</head>
<body>
<div class="receiptContainer">
<center>
<img src="Images/logo.png" width="175px">
<h4>GOKUJOU JAPANESE RESTAURANT</h4>
<p>Total Gas Station, Hibbard Ave., Looc,<br>Dumaguete City, 6200 Negros Oriental, Philippines <br>
09985555175 | 422-1435 <br>
<?php echo date("Y-m-d h:i:sA"); ?>
</p>
<table width="90%" style="text-align: center;">
<tr>
<th>DESCRIPTION</th>
<th>QTY</th>
<th>PRICE</th>
<th>TOTAL</th>
</tr>
<tr>
<td></td>
</tr>
<?php
$query = mysqli_query($con, "SELECT * FROM orders WHERE customerID = '".$_SESSION['customer']."' AND status = 'Checked Out'");
while($row = mysqli_fetch_row($query)){
?>
<tr>
<td><?php echo $row[3]; ?></td>
<td><?php echo $row[5]; ?></td>
<td><?php echo $row[4]; ?></td>
<td><?php echo $row[6]; ?></td>
</tr>
<?php
}
$total = mysqli_query($con, "SELECT SUM(total) AS grandTotal FROM orders WHERE customerID = '".$_SESSION['customer']."' AND status = 'Checked Out' GROUP BY customerID");
$row = mysqli_fetch_row($total);
$sum = $row[0];
?>
<tr>
<tr></tr><tr></tr><tr></tr><tr></tr>
<tr></tr><tr></tr><tr></tr><tr></tr>
<tr></tr><tr></tr><tr></tr><tr></tr>
<td colspan="1" style="text-align: left">GRAND TOTAL: <?php echo $sum; ?></td>
<td colspan="3"></td>
</tr>
<tr style="text-align: left">
<td colspan="1">CASH: <?php echo $_SESSION['cash']; ?></td>
<td colspan="3"></td>
</tr>
<tr style="text-align: left">
<td colspan="1">CHANGE: <?php echo $_SESSION['cash'] - $sum; ?></td>
<td colspan="3"></td>
</tr>
</table>
</center>
</div>
</body>
</html>
This works when I just put a line in the loadHTML () statement, but it returns me an error when I put a PHP file or even static HTML, but static HTML will return line # 3 instead of 4.
source
share