Ich bin mit dieser Sache fest und weiß nicht, was zu tun.Ich habe so viele Male gegoogelt, und habe über fpdf, html2pdf, tcpdf wissen.PHP + HTML-Webseite zu pdf
Ich erstelle eine Rechnung, in der ich html und PHP-Code verwendet habe. Ich möchte diese Daten in pdf anzeigen, um die ganze Seite in pdf umzuwandeln und auch zu drucken und zu speichern. Aber ich weiß nicht was zu tun. Ich bin neu und weiß nicht viel.
Haben versucht, einige Code, aber ich bekomme nur den HTML-Text als Ausgabe auch wollen PHP-Daten zu.
Dies ist die Webseite für Rechnung.
Code: index.php
<?php
if(!isset($_POST['submit']))
{
?>
<form method="post" action=''>
<div id="page-wrap">
<textarea id="header" name="text" disabled="disabled">INVOICE</textarea>
<div id="identity">
<textarea name="address" id="address" disabled="disabled" style="background-color:#FFF;color:#000">Address</textarea>
<div id="logo">
<img id="image" src="images/logo.png" alt="logo" /></div>
</div>
<div style="clear:both"></div>
<div id="customer">
<!-- <textarea id="customer-title" disabled="disabled" style="background-color:#FFF;color:#000">Widget Corp.
c/o Steve Widget</textarea>
-->
<table id="meta">
<tr>
<td class="meta-head">Invoice #</td>
<td><textarea>000123</textarea></td>
</tr>
<tr>
<td class="meta-head">Date</td>
<td><textarea id="date"></textarea></td>
</tr>
</table>
</div>
<table id="items">
<tr>
<th>Item</th>
<th>Unit Cost</th>
<th>Quantity</th>
<th>Price</th>
</tr>
<?php
include("./config.php");
$q=0;$u=0;$t=0;$tt=0;$s=0;$v=0;
$sql="SELECT m.order_id,m.table_id,l.item_id,l.order_quantity,i.item_name,i.item_price from order_m m,order_list l,item_list i where m.order_id=l.order_id and l.item_id=i.item_id and table_id=2";
$result=mysqli_query($con,$sql);
while($row=mysqli_fetch_array($result))
{
$q=$q+$row[3];
$u=$u+$row[5];
$t=$t+($row[3]*$row[5]);
?>
<tr class="item-row">
<td class="item-name"><?php echo $row[4]?></td>
<td><?php echo $row[5];?></td>
<td><?php echo $row[3];?></td>
<td><?php echo $row[3]*$row[5];}?></td>
</tr>
<tr>
<td>Total </td>
<td><?php echo $u; ?></td>
<td><?php echo $q;?></td>
<td><?php echo $t;?></td>
</tr>
<?php
$sql1="Select * from tax";
$res=mysqli_query($con,$sql1);
$row1=mysqli_fetch_row($res);
if($row1[0]!=0)
{
$v=($row1[0]*$t)/100;
?>
<tr>
<td> </td>
<td></td>
<td>VAT%</td>
<td><?php echo $row1[0]."%";?></td>
</tr>
<?php
}
else
{
}
if($row1[1]!=0)
{
$s=($row1[1]*$t)/100;
?>
<tr>
<td> </td>
<td></td>
<td>Service Tax.%</td>
<td><?php echo $row1[1]."%";?></td>
</tr>
<?php
}
else
{
}
?>
<tr>
<td></td>
<td></td>
<td>Total</td>
<td><?php $tt=$t+$v+$s; echo round($tt);?></td>
</tr>
</table>
<div id="terms">
<h5>Terms</h5>
<textarea>NET 30 Days. Finance Charge of 1.5% will be made on unpaid balances after 30 days.</textarea>
</div>
</div>
<input type="submit" name="submit" value="Print" />
</form>
<?php
}
else
{
ob_start();
require("html2pdf.php");
$the_file = "./index.php";
$myfile = fopen($the_file, "r") or die("Unable to open file!!!!<br><br><br>");
$homepage = file_get_contents($the_file);
fclose($myfile);
$pdf = new PDF_HTML();
$pdf->AddPage();
$pdf->SetFont('Arial','B',9);
$pdf->WriteHTML($homepage);
$pdf->Output();
ob_end_flush();
exit;
}
?>
Hier ist die Ausgabe der Umwandlung.
wird es auch PHP-Code rendern? –
ja es wird php auch rendern. –
Fehler erhalten: Bitte legen Sie den Attributpfad fest. Worauf ist dieser Fehler zurückzuführen? –