GitHub - danielwestendorf/breezy-pdf-lite: Simplified, self-hosted, version of b...
source link: https://github.com/danielwestendorf/breezy-pdf-lite
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
BreezyPDF Lite: HTML to PDF generation as a Service
Submit a slug of HTML, get a Google Chrome rendered PDF back.
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.
Looking for something more robust?
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.
Getting Started
1. Submit HTML to be converted
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
.
2. Configure with meta
tags (optional)
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">
View the all the configuration options and their documentation here.
2.a Print OptionsThere are a number of options for how you want the PDF to be rendered, including height, width, margins, footers, and headers.
2.b Completion TriggersYou 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.
Deployment
Heroku
- Click the deployment button to get the system running on Heroku
Clients
Non-Heroku
- Install node & yarn
yarn install
- Set the Environment variables specified below
- Start the web process
node index.js
Configuration
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.
Run Tests
$ /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
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK