Customize PDF invoice output
First of all you can create one page PDF document with empty space where aMember will output invoice information and upload it in PDF Invoice configuration page (Custom PDF template for invoice).
Then specify Top margin - How much [pt] skip from top of template before start to output invoice.
If this customization is not sufficient, you can also customize the aMember output with hooks.
There are four hooks to customize PDF invoices without changing core files:
Two hooks alter the left and right columns before the table:
/** * @param Am_Pdf_Invoice_Col $col * @param User $user * @param Invoice $invoice * @param InvoicePayment|InvoiceRefund $payment */Am_Event::PDF_INVOICE_COL_LEFT; // Customize the left column before the tableAm_Event::PDF_INVOICE_COL_RIGHT; // Customize the right column before the tableExample of usage
You can put the following code to site.php file and this customization will not be affected by upgrade.
Am_Di::getInstance()->hook->add(Am_Event::PDF_INVOICE_COL_LEFT, function (Am_Event $event) { /** @var InvoicePayment|InvoiceRefund $payment */ $payment = $event->getPayment();
$col = $event->getCol(); //print_rre($col); //you can uncomment this line and see what is present in $col object $col->add('Invoice Number: ' . $payment->getDisplayInvoiceId(), 'invoiceNumber'); // alter some line $col->remove('date'); //remove line $col->add('Some additional text'); //add line});Two hooks customize the invoice before or after the table:
/** * @param Am_Pdf_Page_Decorator $page * @param stdClass $pointer use $pointer->value to retrieve current offset and update it * @param User $user * @param Invoice $invoice * @param InvoicePayment|InvoiceRefund $payment */Am_Event::PDF_INVOICE_BEFORE_TABLE; //allow to output any text/graphics before tableAm_Event::PDF_INVOICE_AFTER_TABLE; //allow to output any text/graphics after tableExample of usage
You can put the following code to site.php file and this customization will not be affected by upgrade.
Am_Di::getInstance()->hook->add(Am_Event::PDF_INVOICE_BEFORE_TABLE, function (Am_Event $event) { /** @var $page Am_Pdf_Page_Decorator */ $page = $event->getPage(); $pointer = $event->getPointer();
$pointer->value = $page->drawTextWithFixedWidth(<<<CUT Some text to output on invoice above table, it can be longtext and new line will be added automatically by demandCUT , 20, $pointer->value, 200);});Change the order of the lines
For example if you want the date before the invoice number plus a custom value
Example of usage
You can put the following code to site.php file and this customization will not be affected by upgrade.
Am_Di::getInstance()->hook->add(Am_Event::PDF_INVOICE_COL_LEFT, function (Am_Event $event) { /** @var InvoicePayment|InvoiceRefund $payment */ $payment = $event->getPayment(); $col = $event->getCol(); $col->moveBefore('date', 'invoiceNumber'); $col->prepend('Reçu de transaction'); //prepend line});Copyright © 2002–2026 www.amember.com. All Rights Reserved.