Customize Magento PDF Layout
With my Advanced Invoice Layout Extension for Magento it is very easy to create individual layouts for Magento PDF invoices, shipments and creditmemos.
Want to see some examples? Check out some sample invoice layouts from our customers.
Customizing the PDF Invoice Layout
The extension ships with a base HTML layout that already fits for many cases. Furthermore we will release more enhanced step by step so that you can customize the PDF layout without any effort.
Your own customizations can be done with HTML/CSS.
For more experienced users we also deliver SASS files that allows an easier modification of e.g. colors in the whole document.
Please see also how to customize the payment block in the Magento PDF invoice.
Basically it is always recommended to activate the Debug Mode of the AdvancedInvoiceLayout extension for testing different layouts under Stores -> Configuration -> Advanced Invoice Layout. With activated Debug Mode the intermediate HTML file will be saved with each print of the PDF invoice, shipment or creditmemo into the directory var/tmp/invoice_debug.html
. Therewith you can analyze and customize the HTML structure and CSS style sheets more easily.
However you are advised to disable this setting in production environments for performance reasons.
Please see also the available variables.
Instructions for Magento 2
We recommend to do your own customizations within these files in your custom theme folder to avoid loosing changes in case that the Extension got an upgrade.
To do that create a new folder Vianetz_AdvancedInvoiceLayout
and a subfolder templates/default
in your theme directory in app/design/frontend/MYTHEME/MYTHEME/
and copy the files that you want to customize into the newly created directory.
Instructions for Magento 1/OpenMage
Your own customizations can be done with HTML/CSS. The appropriate files are in the following directoriesapp/design/frontend/base/default/template/advancedinvoicelayout/default
skin/frontend/base/default/advancedinvoicelayout/default/css
We recommend to do your own customizations within these files in your custom theme folder to avoid loosing changes in case that the Extension got an upgrade.
I.e. assuming that your Magento theme is in folder app/design/frontend/MYTHEME/default/
and you want to customize the invoice layout we recommend to copy the file app/design/frontend/base/default/template/advancedinvoicelayout/invoice.phtml
to app/design/frontend/MYTHEME/template/default/advancedinvoicelayout/invoice.phtml
.
Frequently Asked Questions
Change font family in Magento PDF invoice layout
Show custom attributes on Magento invoice
Activate PDF email attachment feature with other email extensions like Ebizmarts_Mandrill
Available Variables for Magento PDF Layouts
Cyrillic characters are displayed as "?" on the Magento PDF invoice. What can I do?
The problem is that the chosen font family does not support the Cyrillic characters. So far no font with Cyrillic support is included into the Advanced Invoice Layout Extension. That means that you have to get your own font family with support for Cyrillic characters and include it into the Advanced Invoice Layout Extension.
Please also see my FAQ article about adding a new font.
DHL Location Finder Extension: Post number is printed multiple times in address
If you are using our Advanced Invoice Layout Extension with the DHL Extension Dhl_LocationFinder
it may happen that if you have added the post number in the shipping address with the variable
{{var dhl_post_number}}
you will see the following output on the PDF invoice or shipment document:Postnumber: Postnumber: Postnumber: Postnumber: Postnumber: Postnumber: Postnumber: Postnumber: 32403197
This issue happens due to a small bug in the DHL Extension that listens to the Magento event customer_address_format
and adds the "Postnumber: " prefix. But as this event can occur multiple times (as it will within the Advanced Invoice Layout extension) the prefix is also added multiple times.
As this is not the desired behaviour you can patch the method Dhl_LocationFinder_Model_Observer::addPostNumberLabel()
to only add the prefix once:
public function addPostNumberLabel(Varien_Event_Observer $observer)
{
$address = $observer->getData('address');
$postNumberLabel = Mage::helper('dhl_locationfinder/data')->__('Postnumber: ');
if ($address->getData('dhl_post_number') && strpos($address->getData('dhl_post_number'), $postNumberLabel) === false) {
$postNumberString = $postNumberLabel . $address->getData('dhl_post_number');
$address->setData('dhl_post_number', $postNumberString);
}
}
Please note that this was tested with Dhl_LocationFinder extension version 1.0.3.
How can I access the base64-encoded PDF file?
There may be circumstances where you need the base64-encoded value of one of the PDF documents in Magento 2 like creditmemo, e.g. for sending it other 3rd-party systems.
This can easily be achieved with the following sample code. This code assumes that you have \Vianetz\AdvancedInvoiceLayout\Model\PdfManager $pdfManager
and e.g. \Magento\Sales\Api\CreditmemoRepositoryInterface $creditmemoRepository
available, for example via Constructor Dependency Injection or as shown by direct Magento 2 Object Manager creation.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$pdfManager = $objectManager->create('Vianetz\AdvancedInvoiceLayout\Model\PdfManager');
$creditmemo = $objectManager->create('Magento\Sales\Api\CreditmemoRepositoryInterface')->get($creditmemoId);
$pdfManager->addSource($creditmemo);
// output the base64-encoded value
echo base64_encode($this->pdfManager->getPdf()->getContents());
This code uses parts of my PDF API for Magento.
How can I configure the address format?
How can I configure the tax format on the PDF invoice?
- System › Configuration › Advanced Invoice Layout › General › Tax Display: Including Tax
- System › Configuration › Tax › Orders, Invoices, Credit Memos Display Settings › Include Tax In Grand Total: Yes
- System › Configuration › Tax › Orders, Invoices, Credit Memos Display Settings › Display Full Tax Summary: Yes
(if this is set to "No" tax is not splitted into percent classes)
How can I create different PDF invoice layouts for different Magento store views?
With our Advanced Invoice Layout Extension for Magento you can easily create store view specific layouts, texts, logos or colors. Therefore you can easily change the store view switcher on the Advanced Invoice Layout configuration page in the Magento backend.
If you want further more layout customizations to the HTML files there are 2 possibilities:
- If you use already different Magento themes you can easily do the customizations in the appropriate theme folder. I.e. you just do the customizations e.g. in
app/design/frontend/theme1/default/advancedinvoicelayout
andapp/design/frontend/theme2/default/advancedinvoicelayout
. - Additionally there is the possibility (e.g. if you use the same theme for both store views) to create own themes in the Advanced Invoice Layout Extension.
How can I customize the payment block in the Magento PDF invoice?
How can I display the Amazon Order Id on the Magento PDF invoice?
echo Mage::helper('M2ePro/Component_Amazon')->getModel('Order')
->load($this->getOrder()->getId(), 'magento_order_id')
->getChildObject()->getAmazonOrderId();
You can find more information in our FAQ on how to customize the templates. How can I force a page break in the Magento invoice PDF?
A page break can be forced in the invoice PDF by adding an HTML element with the CSS class pageBreak
.
How can I move the logo on the Magento PDF invoice to the left?
If you use our extension Advanced Invoice Layout for Magento it is very easy to move the logo on the PDF documents (invoice/shipment/creditmemo) to the left or right. Just enter the following CSS snippet into System › Configuration › Advanced Invoice Layout › Custom CSS to move the logo to the left:
#header #storeLogo { text-align: left; }
How can I print barcodes on the Magento PDF invoice?
With our Advanced Invoice Layout Extension for Magento it is very easy to print barcodes of any code on the Magento PDF invoice, shipment or creditmemo.
All you have to do is to choose a font family that supports your desired barcode format and use that in the Advanced Invoice Layout CSS file for printing the barcode. Voilà!
How can I show additional text in tax-free PDF invoices in Magento?
Our Advanced Invoice Layout Extension for Magento allows you to have customer group specific texts on the PDF invoice document.
Therefore on the customer group configuration page in the Magento admin panel there is an additional text field where you can enter HTML-text that will be displayed on PDF invoices if the customer is contained in that customer group.
How do I get the Advanced Invoice Layout extension to work with module AITOC Checkout Fields Manager?
Mage_Sales_Model_Order_Pdf_Invoice
there. Migrate Advanced Invoice Layout templates from Magento 1 to Magento 2
If you use our Advanced Invoice Layout extension for Magento 1 and you want to migrate your shop to Magento 2, there are a few simple steps to make the invoice, packing slips and creditmemo PDF look nice:
- Purchase the Advanced Invoice Layout extension for Magento 2
- Copy all your template files from the Magento 1 extension from
app/design/frontend/base/default/template/advancedinvoicelayout
to the Magento 2 extension inview/base/templates/
- Copy all the CSS files from Magento 1 from
skin/frontend/base/default/advancedinvoicelayout
to the Magento 2 extension inview/base/web/
- Replace all occurrences of
$this->__( .. %s .. )
with$this->__( .. %1 .. )
Print the telephone number on the Magento pdf invoice
Printing the telephone number of the customer on the Magento pdf invoice, shipment or creditmemo is very easy with our Advanced Invoice Layout Extension.
All you have to do is go to System › Configuration › Customer Configuration › Address Templates and in the field Advanced Invoice Layout PDFs add the following variable:
{{var telephone}}
This field accepts HTML source code, i.e. you can add line breaks (<br>
) or plain text as you like.
Schweizer QR-Rechnung mit Magento generieren
Sample PDF Layouts
Kunde seit 2013
Kunde seit 2014
Kunde seit 2011
Kunde seit 2014
Kunde seit 2014
Kunde seit 2013
Kunde seit 2009
Kunde seit 2017
Kunde seit 2013
Kunde seit 2016
Kunde seit 2014
Kunde seit 2020
Wenn Sie meine Magento Extension im Einsatz haben und gerne Ihr PDF-Layout hier präsentieren möchten oder eine Aufnahme als PDF-Template in die Extension ermöglichen können, freue ich ich jederzeit über eine Kontaktaufnahme.