I′ve started using HTML2PDF (https://www.html2pdf.fr/) to create invoices, now the following code works:
try {
ob_end_clean();
ob_start();
include('../faktura/fa.php');
$html = ob_get_contents();
ob_end_clean();
$content = $html;
$html2pdf = new Html2Pdf('P', 'A4', 'cs',true,"UTF-8");
$html2pdf->setDefaultFont('freeserif');
$html2pdf->pdf->SetFont('freeserif');
$html2pdf->writeHTML($content);
$pdfContent = $html2pdf->output('my_doc.pdf', 'S');
} catch (Html2PdfException $e) {
$html2pdf->clean();
$formatter = new ExceptionFormatter($e);
echo $formatter->getHtmlMessage();
}
The content of fa.php
is converted to pdf, however if I change one of the lines to:
include('../faktura/fa.php?id=105');
note that I only added ?id=105
, it returns only a blank page.
The php file fa.php includes:
$id = (int) $_GET['id'];
What I need to do is to pass an ID to that php script so the invoice of the exact order is generated.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…