Giter Club home page Giter Club logo

breezy-pdf-lite's Introduction

BreezyPDF Lite: HTML to PDF generation as a Service

Submit a slug of HTML, get a Google Chrome rendered PDF back.

Build Status Coverage Status

Deploy

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">
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.

2.a Print Options

There are a number of options for how you want the PDF to be rendered, including height, width, margins, footers, and headers.

2.b Completion Triggers

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.

Deployment

Heroku

Deploy

  1. Click the deployment button to get the system running on Heroku

Clients

Non-Heroku

  1. Install node & yarn
  2. yarn install
  3. Set the Environment variables specified below
  4. 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

breezy-pdf-lite's People

Contributors

danielwestendorf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.