PDF from HTML

Last updated: November 6th 2023

You can turn up your HTML variable into pdf. All you have to do is to set the variable and pass to Super PDF.

Basic Example
{% set html %}
	<h1>This is a basic example</h1>
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.</p>
{% endset %}

{% set settings = {
    filename: "My_PDF",
} %}

{{ craft.superpdf.html(html, settings) }}
Basic Example to get PDF URL and other meta data
{% set html %}
	<h1>This is a basic example</h1>
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod.</p>
{% endset %}

{% set settings = {
    filename: "My_PDF",
    type: 'object'
} %}

{% set object = craft.superpdf.html(html, settings) %}

// Printing object will return url by default.
PDF URL is: {{ object }}

// Object can be use to print different variables like this:
{{ object.filename }}
{{ object.kind }}
{{ object.size }}
{{ object.dateModified }}
{{ object.path }}
{{ object.url }}