Download the PHP package kennethormandy/craft-api2pdf without Composer
On this page you can find all versions of the php package kennethormandy/craft-api2pdf. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kennethormandy/craft-api2pdf
More information about kennethormandy/craft-api2pdf
Files in kennethormandy/craft-api2pdf
Package craft-api2pdf
Short Description Generate PDFs using api2pdf.com
License MIT
Informations about the package craft-api2pdf
Api2Pdf plugin for Craft CMS
Generate PDFs easily, using Api2Pdf.com
Requirements
This plugin requires Craft CMS 3.1.x or later, or Craft 4.0.0 or later.
Installation
The Craft 4 version of the plugin is currently tagged as a beta release. You can install it with:
Otherwise, require the plugin using Composer like normal:
Then, in the Craft CMS Control Panel, go to Settings → Plugins, and click the “Install” button for Craft Api2Pdf. Or run:
Settings
The only setting required to run the plugin is an API key from Api2Pdf, which can (and probably should) be set to an environment variable:
Actions
api2pdf/pdf/generate-from-url
api2pdf/pdf/generate-from-html
api2pdf/pdf/merge
Twig
craft.api2pdf.generateFromUrl
craft.api2pdf.generateFromHtml
craft.api2pdf.merge
Options
Option | Type | Description |
---|---|---|
filename |
String | |
redirect |
Boolean | Redirect directly to the PDF URL |
filename
redirect
All advanced options for Headless Chrome to pass along to Api2Pdf are also supported.
Examples
Action generate-from-url
Get the JSON response from Api2Pdf:
Redirect directly to the PDF url:
Action generate-from-html
Redirect directly to the PDF made using an HTML string:
Offer an editable filename:
Action merge
Merge two hosted PDFs (generated by this plugin or otherwise), into one:
These URLs passed to this function need to be hosted PDFs. Whether or not they were previously generated via this plugin previously, or whether they are on your server doesn’t matter, as long as they are accessible at the URL.
Twig generateFromUrl
function
Twig generateFromHtml
function
Slightly more detailed example:
Twig merge
function
Notes
- This plugin is build for v1 of the Api2Pdf API, but support for the v2 endpoint may be added when it’s out of beta, the Api2Pdf client libraries are also updated
- This plugin only supports Headless Chrome for PDF generation. If you are interested in adding support for another endpoint, I’d be open to discussing a Pull Request (but note the v2 API also only supports Headless Chrome).
License
The MIT License (MIT)
Copyright © 2019–2020 Kenneth Ormandy Inc.