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.
Include
basically means "copy the code from that file to here".
So if you change the included file code from $id = (int) $_GET['id']; to $id = $thatId;
And prior to the include() function you'd write $thatId = 105; The included file will be able to access the variable.
File A:
$id = 105;
include('../faktura/fa.php');
File fa.php
//$id = (int) $_GET['id']; // no need this anymore as we've declared a $id variable with a value;
// .. Do something with $id
// .. for example:
echo $id; //will print 105
Or, in case you want fa.php to continue working with QUERY PARAMETER and to work with your invoice (2pdf) code:
if(!isset($id) && isset($_GET['id'])) {
$id = (int) $_GET['id'];
}
Displaying Dynamic placeholder content on Textbox in ReactJS
Extracting Parameters from Redirect URI - QuickBooks API / Python
How to check if a function is running in worker thread in node?
How to take column from two table in whereExists clause in laravel 5.5
Cannot publish new release to Google Play because of Sensitive app permissions
I have a drop down menu in sidebar and it has links as menu itemsWhen I click a menu item(link) then link works fine but drop down menu gets closed
I am trying to create a user in mongoose and return it after Usercreate query without password field
I want to use python3 to generate random password to encrypt my files, The random password created should have following restriction
I am taking a screenshot on my android app using this code: