Downloading Invoice PDF
Basics
An existing invoice can be downloaded as a PDF document. The implementation is illustrated in the following example file:
./examples/document/invoice/get_invoice_pdf.php
tip
Downloading the Invoice PDF can be done based on either the invoice number or the order number. When downloading based on the order number, the last document with this order number is returned.
// Download based on invoice number:
$agent->getInvoicePdf('TESZT-001');
// Download based on order number:
$agent->getInvoicePdf('TESZT-001', Invoice::FROM_ORDER_NUMBER);
// Download based on external invoice ID:
$agent->getInvoicePdf('TESZT-001', Invoice::FROM_INVOICE_EXTERNAL_ID);
// The response is a PDF type invoice, which can be downloaded as follows:
$result->downloadPdf(fileName);
The filename is not mandatory. If not provided, the invoice number will be used as the PDF file name.
Expected and Optional Inputs
Invoice Data
Description | Field | Type | Required | Default |
---|---|---|---|---|
Invoice number | invoiceNumber | string | yes | |
Order number | orderNumber | string | ||
PDF download | downloadPdf | boolean | false |