Receipt PDF Download
Basics
An existing receipt can be downloaded as a PDF using the receipt number or order number with the same method; the second argument selects the identifier type. The downloadable package includes ./examples/document/receipt/get_receipt_pdf.php for the receipt-number case; see the code sample below for getReceiptPdf with an order number.
tip
Order-number-based download follows the same “last matching document” behaviour as querying receipt data.
use SzamlaAgent\Document\Receipt\Receipt;
// Receipt number (default):
$agent->getReceiptPdf('NYGTA-2021-001');
// Order number:
$agent->getReceiptPdf('ORD-2026-0042', Receipt::FROM_ORDER_NUMBER);
// Document::FROM_ORDER_NUMBER is the same value.
// Response is PDF; download with an optional file name:
$result->downloadPdf();
// $result->downloadPdf('/path/to/file.pdf');
The file name is optional. If omitted, the receipt number is used as the PDF file name.
For the order number at generation time, see Receipt generation. For data query, see Querying receipt data.
Expected and Optional Inputs
Receipt Header Data
| Description | Field | Type | Required | Default |
|---|---|---|---|---|
| Receipt number | receiptNumber | string | yes* | |
| Order number | orderNumber | string | yes* | |
| PDF template | pdfTemplate | string |
* Provide exactly one of receiptNumber or orderNumber for getReceiptPdf.