HTML と php を使用して作成した動的 Web ページがあります...静的 Web ページを pdf に変換できるサンプル コードが既にあります...しかし、私の問題は、Web ページが動的であることです...ページを pdf に変換しますか? とにかく、ここに私のコードがあります:
<?php
include_once("../classes/Receipt.php");
include_once("../classes/SalesDetail.php");
include_once("../classes/Business.php");
//session variable
$userID = 1;
$receipt = &new Receipt();
$receipt->queryReceiptInfo($userID);
$receiptID = $receipt->getReceiptID();
$receiptIssueDate = $receipt->getReceiptIssueDate();
$customer = $receipt->getCustomer();
$salesID = $receipt->getSalesID();
$salesDetail = &new SalesDetail($salesID);
$salesDetails = $salesDetail->viewSalesDetail();
//session variable
$businessID = 1;
$business = &new Business('', $businessID);
$business->queryBusinessName();
$businessName = $business->getBusinessName();
$rows = sizeof($salesDetails);
$columns = sizeof($salesDetails[0]);
?>
<table>
<tr>
<td>Receipt No.</td>
<td><?php echo $receiptID; ?></td>
<tr>
<tr>
<td>Date Issued</td>
<td><?php echo $receiptIssueDate; ?></td>
</tr>
<tr>
<td>Business</td>
<td><?php echo $businessName; ?></td>
</tr>
<tr>
<td>Customer</td>
<td><?php echo $customer; ?></td>
</tr>
</table>
<table>
<tr>
<td>Item</td>
<td>Quantity</td>
<td>Sub-Total</td>
</tr>
<?php
$totalPrice = 0;
for ($i = 0; $i < $rows; $i++) {
echo "<tr>";
for($j = 0; $j < $columns; $j++) {
echo "<td>".$salesDetails[$i][$j]."</td>";
}
$totalPrice += (double)$salesDetails[$i][2];
echo "</tr>";
}
?>
<tr>
<td></td>
<td>Total Price</td>
<td><?php echo $totalPrice;?></td>
</tr>
</table>