Using the sample code provide by amembre on PDF invoice customization, I failled to find a way to change the order of element being displayed on the invoice. I would like to read in the left column the following elements in this sequence: - Some title text ("Receipt") - Date - invoiceNumber When using the code below the order is ignored and the invoice shows: - invoiceNumber - Date - Some title text ("Receipt") Code: Am_Di::getInstance()->hook->add(Am_Event::PDF_INVOICE_COL_LEFT, function (Am_Event $event) { /* @var $payment InvoicePayment */ $payment = $event->getPayment(); $col = $event->getCol(); $col->custom = 'Reçu de transaction'; //add line $col->date; $col->invoiceNumber; }); Any help would be appreciated.
The solution is unset existing line and set it in new order eg.: PHP: Am_Di::getInstance()->hook->add(Am_Event::PDF_INVOICE_COL_LEFT, function (Am_Event $event) { /* @var $payment InvoicePayment */ $payment = $event->getPayment(); $col = $event->getCol(); $col1 = clone $col; $col->custom = 'Reçu de transaction'; //add line unset($col->date); unset($col->invoiceNumber); $col->date = $col1->date; $col->invoiceNumber = $col1->invoiceNumber;});
Great! I guessed that the solution but I could not find the way to do it. Thanks! How could I change the font size of a col->custom like this one?: $col->custom = 'Reçu de transaction';
I have updated the wiki page http://www.amember.com/docs/How_to_customize_PDF_invoice_output with this example
I implemented better API for such task. It will be included to upcoming release (5.1.1). Here is example of usage: PHP: Am_Di::getInstance()->hook->add(Am_Event::PDF_INVOICE_COL_LEFT, function (Am_Event $e) { $col = $e->getCol(); $col->addBefore('Reçu de transaction', 'date'); //add text before date line $col->moveAfter('invoiceNumber', 'date'); //move invoice number line after date line}); Full interface is: PHP: interface Am_Pdf_Invoice_Col{ function add($text, $token = null); function remove($token); function addBefore($text, $ref, $token = null); function addAfter($text, $ref, $token = null); function moveBefore($token, $ref); function moveAfter($token, $ref);}