Skip to content

This Module let's you easily create PDF's based on HTML Templates or by using the default Templates and adding the content you want.

Notifications You must be signed in to change notification settings

staempfli/magento-pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Staempfli PDF

Project Status: Abandoned – Initial development has started, but there has not yet been a stable, usable release; the project has been abandoned and the author(s) do not intend on continuing development.

Facts

Description

This Module let's you easily create PDF's based on HTML Templates or by using the default Templates and adding the content you want.

Load the Module

$pdf = Mage::getModel('staempfli_pdf/pdf');

or extend the the PDF Model in your own Model, like:

<?php
class Vendor_Extension_Model_Pdf extends Staempfli_Pdf_Model_Pdf
{
}

Define a Header, Footer and/or Content part.

$header   = $pdf->createBlock('staempfli_pdf/pdf_header');
$footer   = $pdf->createBlock('staempfli_pdf/pdf_footer');
$content  = $pdf->createBlock('staempfli_pdf/pdf_content');

Now you are ready to add some Content and/or add custom Stylesheets.

Add a custom Stylesheet:

$content->addStylesheet('/skin/frontend/your_theme/default/css/pdf.css');

Set a Title:

$content->setTitle('My Page Title');

Add a Section:

$content->addSection('header');
// here you can define your Content by ->addContent
// or adding an Image with ->addImage()
$content->endSection();

Add Content:

// Plain Text
// Output:
// Hello World

$content->addContent('Hello World');

// Wrap content between an element
// Output:
// <h1>Hello World</h1>

$content->addContent('Hello World', 'h1');

// Add some attributes to an element
// Output:
// <h1 class="content">Hello World</h1>

$content->addContent('Hello World', 'h1', array('class' => 'custom'));

Add an Image:

$content->addImage('/skin/frontend/your_theme/default/images/my-logo.svg');

// With image title
$content->addImage('/skin/frontend/your_theme/default/images/my-logo.svg', 'Title');

Now, create a Page based on your Content

$pdf->addPage($content->toHtml());

Download the PDF:

$pdf->downloadPdf('filename.pdf');

Save the PDF:

$pdf->savePdf('filename.pdf');

Custom options

Setp page size (A4, Letter)

$pdf->setPageSize('A4');

Set orientation:

$pdf->setOrientation('Portrait');

Set Temporary Directory:

$pdf->setTmpDir('/path/to/your/tmp/dir');

Requirements

Compatibility

  • Magento >= 1.7

Installation Instructions

  1. Install the extension via Composer or copy all the files into your document root.
  2. Clear the cache, logout from the admin panel and then login again.

Uninstallation

  1. Remove all extension files from your Magento installation.

Support

If you have any issues with this extension, open an issue on GitHub.

Contribution

Any contribution is highly appreciated. The best way to contribute code is to open a pull request on GitHub.

Developer

Staempfli Webteam and all other contributors

License

GNU General Public License, version 3 (GPLv3)

Copyright

(c) 2016, Stämpfli AG

About

This Module let's you easily create PDF's based on HTML Templates or by using the default Templates and adding the content you want.

Resources

Stars

Watchers

Forks

Packages

No packages published