AdvancedInvoiceLayout: API for Magento Developers

Magento developers can use the AdvancedInvoiceLayout Extension to either customize the default look'n'feel of the Magento PDF invoices, shipments and creditmemos or alternatively to implement their own PDF printing extension based on the ready-to-use vianetz PDF API.
The latter opportunity is explained here:

Implementing your own PDF Extension by using the AdvancedInvoiceLayout PDF Engine API

Together with the AdvancedInvoiceLayout Extension we bundle the vianetz PDF Engine API that enables you as a developer to build your custom solution for PDF printing, e.g. to allow users to save the product detail page in your Magento store as PDF file or to create completely individual PDF documents with easy HTML/CSS styling.
Therefore we describe the public API of the vianetz PDF Engine as follows:

Class Vianetz_Pdf_Model_Pdf
  • addDocument(Vianetz_Pdf_Model_Document_Interface): Add a new document to the PDF instance
  • getContents(): Return the PDF file contents
  • saveToFile(string): Generate and save the current PDF contents to specified file name

The magic lies in the Vianetz_Pdf_Model_Document_Interface which asks you to implement the following method:
  • getHtmlContents(): Return the HTML contents that should be converted into PDF

Sample Usage


class Your_Document implements Vianetz_Pdf_Model_Document_Interface {
     * This fetches the product detail page content for product id 1.
     * You can return any kind of HTML content here.
    public function getHtmlContents()
        $block = Mage::getBlockSingleton('catalog/product_view')

        return $block->toHtml();

// Create a new pdf instance.
$pdf = new Vianetz_Pdf_Model_Pdf();

// Add our document class. You can add as many documents as you like
// as they will all be merged into one PDF file.
$pdf->addDocument(new Your_Document());

// Save the resulting PDF to file test.pdf - That's it :-)

Please get in touch with us if you have any questions.