A ruby client for BreezyPDFLite, a one-click-to-deploy microservice for converting HTML to PDF with Google Chrome. Send the library a chunk of HTML, get a PDF of it back. Configure how the PDF is rendered via meta
tags in the HTML.
Use pragmatically, or as a Rack Middleware.
Add this line to your application's Gemfile:
gem 'breezy_pdf_lite'
And then execute:
$ bundle
Or install it yourself as:
$ gem install breezy_pdf_lite
BreezyPDFLite requires some configuration before you can use it. Somewhere in your application (perhaps in config/intializers/breezy_pdf_lite.rb
), configure the base_url
and the secret_api_key
of your service. Get these from your Heroku configuration.
BreezyPDFLite.setup do |config|
config.secret_api_key = ENV["BREEZYPDF_SECRET_API_KEY"]
config.base_url = ENV.fetch("BREEZYPDF_BASE_URL", "http://localhost:5001")
end
Add the Middleware to your stack.
Ruby on Rails
# config/application.rb
config.middleware.use BreezyPDFLite::Middleware
Any URL ending in .pdf
will be intercepted, rendered as HTML, rendered to a PDF, and then returned to the client.
Rack/Sinatra/etc
See example/config.ru
See example/pragmatic.rb
Examples depend on the BreezyPDFLite microservice being avialable.
Middleware
BREEZYPDF_SECRET_API_KEY=YOURSECRETKEY BREEZYPDF_BASE_URL=https://YOURHEROKUAPPORWHATEVER.herokuapp.com/ rackup example/config.ru
Visit https://localhost:9292
and click the link to download the PDF.
Pragmatic
BREEZYPDF_SECRET_API_KEY=YOURSECRETKEY BREEZYPDF_BASE_URL=https://YOURHEROKUAPPORWHATEVER.herokuapp.com/ ruby example/pragmatic.rb
The PDF will be downloaded to example/example.pdf
See LICENSE.txt
.