Generating a PDF

Basic Usage

Printmaker provides methods to create a new PDF file from HTML or template source.

These methods will return a PdfModel object, which allows you to edit, output, download, save, or send the generated PDF via your template.

You can supply HTML code directly using the pdfFromHtml method, or generate a PDF from a compiled template using the pdfFromTemplate method.

printmaker.pdfFromHtml

The pdfFromHtml() method accepts two parameters:

{% set html %}
<html>Howdy, world!</html>
{% endset %}
{% set settings = { orientation : 'portrait' } %}
{% set pdf = craft.printmaker.pdfFromHtml(html, settings) %}

printmaker.pdfFromTemplate

The pdfFromTemplate() method accepts three parameters:

{% set vars = { title: 'Howdy, world!', foo: entry.fooField } %}
{% set settings = { orientation : 'portrait' } %}
{% set pdf = printmaker.pdfFromTemplate('_pdf/_myTemplate', vars, settings) %}