This article was contributed by a member of the Heroku community
Its contents might not always reflect updates to the Heroku platform.
This add-on is operated by BreezyPDF
Generate beautiful PDF documents from the HTML you already have
BreezyPDF
Last updated October 01, 2018
The BreezyPDF add-on is currently in beta.
Table of Contents
BreezyPDF is an add-on for generating beautiful PDF documents.
Create complex and beautiful PDFs using the technologies you already know and love with minimal configuration. BreezyPDF provides full support for modern HTML, JavaScript, and CSS technologies, including charts, SVG, images, and canvas elements. There are no libraries to configure, UX to figure out, or fonts to install.
Provisioning the add-on
BreezyPDF can be attached to a Heroku application via the CLI:
A list of all plans available can be found here.
$ heroku addons:create breezypdf
-----> Adding breezypdf to sharp-mountain-4005... done, v18 (free)
After you provision BreezyPDF, the BREEZYPDF_SECRET_API_KEY
config var is available in your app’s configuration. It contains the secret API key for access to the BreezyPDF API. You can confirm this via the heroku config:get
command:
$ heroku config:get BREEZYPDF_SECRET_API_KEY
sk_e4dc1a4d397e7af5b82a38749f3fd1d1
After you install BreezyPDF, your application should be configured to fully integrate with the add-on.
Local setup
BreezyPDF has complete support for localhost
and other development environments. For the best user experience, make sure to properly configure BreezyPDF for your specific environment’s needs.
Environment setup
After you provision the add-on, it’s necessary to locally replicate its config vars so your development environment can operate against the service.
Use the Heroku Local command-line tool to configure, run, and manage process types specified in your app’s Procfile. Heroku Local reads configuration variables from a .env
file. To view all of your app’s config vars, type heroku config
. Use the following command for each value that you want to add to your .env
file:
$ heroku config:get BREEZYPDF_SECRET_API_KEY -s >> .env
Credentials and other sensitive configuration values should not be committed to source-control. In Git exclude the .env
file with: echo .env >> .gitignore
.
For more information, see the Heroku Local article.
Service setup
BreezyPDF can be installed for use in a local development environment. Typically this entails creating another version of the service and pointing the BREEZYPDF_SECRET_API_KEY to this remote service.
Using with Ruby on Rails or other Rack-based web frameworks (Sinatra, Hamani, etc.)
Ruby applications need to add the following entry into their Gemfile
specifying the BreezyPDF client library:
gem 'breezy_pdf'
Update application dependencies with bundler:
$ bundle install
Configure the BreezyPDF client:
# config/initializers/breezypdf.rb
BreezyPDF.setup do |config|
config.secret_api_key = ENV["BREEZYPDF_SECRET_API_KEY"]
config.upload_assets = Rails.env.development?
end
BreezyPDF is highly configurable depending on your environment’s needs. See the library configuration options here.
Configure Rails to use the BreezyPDF middleware:
# config/application.rb
config.middleware.use BreezyPDF::Middleware
Add a link to the web page you’d like to be converted to a PDF:
# view.html.erb
<%= link_to "Download as PDF", my_resource_path(format: :pdf) %>
Additional setup and configuration details can be found here.
Using with other languages
Support for additional languages is coming soon.
Monitoring and logging
You can monitor BreezyPDF activity within the Heroku log-stream by filtering for messages containing BreezyPDF
:
$ heroku logs -t | grep 'BreezyPDF'
Dashboard
For more information on the features available within the BreezyPDF dashboard, please see the docs at mysite.com/docs.
The BreezyPDF dashboard allows you to view your rendering usage and configure global options.
You can access the dashboard via the CLI:
$ heroku addons:open breezypdf
Opening breezypdf for sharp-mountain-4005
or by visiting the Heroku Dashboard and selecting the application in question. Select BreezyPDF from the Add-ons menu.
Migrating between plans
Application owners should carefully manage the migration timing to ensure proper application function during the migration process.
Migrating between plans will instantly reflect the rendering credits available in the given month.
Use the heroku addons:upgrade
command to migrate to a new plan.
$ heroku addons:upgrade breezypdf:standard-1
-----> Upgrading breezypdf:standard-1 to sharp-mountain-4005... done, v18 ($49/mo)
Your plan has been updated to:breezypdf:standard-1
Removing the add-on
You can remove breezypdf via the CLI:
This will disable PDF rendering and remove any retained PDFs immediately.
$ heroku addons:destroy breezypdf
-----> Removing breezypdf-SLUG from sharp-mountain-4005... done, v20 (free)
Before removing BreezyPDF, ensure that any previously rendered PDFs have been downloaded, and that URLs you’ve shared with your users referencing those PDFs have been updated.
Support
All BreezyPDF support and runtime issues should be submitted via one of the Heroku Support channels. Any non-support related issues or product feedback is welcome at support@breezypdf.com.