A quick to stand up HTML to PDF service powered by headless Google Chrome. Deploy with one click and start generating PDF's from your web application or command line.
BreezyPDF Lite was extracted from BreezyPDF as a light weight alternative for new apps. As your software grows, a 1:1 server instance/render ratio will become slow and limiting.
See BreezyPDF.com for Hosted and Enterprise versions which prioritize performance, redundancy, and usability.
This is done with a POST
request the the web server. We'll use some example HTML for this example.
curl -X POST -H 'Authorization: Bearer PRIVATE_TOKEN_DEFINED_IN_SERVER_ENVIRONMENT' \
http://url-of-your-breezy-pdf-lite-server/render/html \
-d "`curl https://raw.githubusercontent.com/danielwestendorf/breezy-pdf-lite/master/sample.html`" \
-o example.pdf
This will create the PDF in the current directory by the name of example.pdf
.
All configuration for the rendering of your PDF can be configured by meta tags within the HTML you submit. Simply insert the needed meta tag into the head or body of the HTML.
<meta name="breezy-pdf-width" content="10">
Tag name | Default Value | Description |
---|---|---|
breezy-pdf-width | 8.5 | PDF page width in inches |
breezy-pdf-height | 11 | PDF page height in inches |
breezy-pdf-cssPageSize | false | Use page size defined by CSS |
breezy-pdf-marginTop | 0.4 | Top margin |
breezy-pdf-landscape | false | Print in landscape mode |
View the all the configuration options and their documentation here.
There are a number of options for how you want the PDF to be rendered, including height, width, margins, footers, and headers.
You might be rendering a Javascript heavy page, so it's helpful to let chrome
know when the page is done rendering and ready to be converted to PDF. The default completion trigger is a timer of 5000ms.
- Click the deployment button to get the system running on Heroku
- Install node & yarn
yarn install
- Set the Environment variables specified below
- Start the web process
node index.js
Set the Environment/Heroku Config Vars
ENV Variable | Default Value | Description |
---|---|---|
PRIVATE_API_TOKEN | generated secret | A private key for accessing the API. |
Set DEBUG
Config var to breezy-pdf-lite:*
to get debugged output.
$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --interpreter none --headless --disable-gpu --disable-translate --disable-extensions --disable-background-networking --safebrowsing-disable-auto-update --disable-sync --metrics-recording-only --disable-default-apps --no-first-run --mute-audio --hide-scrollbars --remote-debugging-port=9222
$ npm test