Giter Club home page Giter Club logo

heroku-pdf's Introduction

Heroku PDF Generation

Based on

Summary

A rails sample app that generates PDFs from html, works on heroku.com and is so painless it hurts.

Install steps:

  • sudo gem install heroku (if not already installed)
  • git clone git://github.com/jordan-brough/heroku-pdf.git
  • cd heroku-pdf
  • heroku create your-great-app-name --stack bamboo-ree-1.8.7
  • git push heroku master
  • visit http://your-great-app-name.heroku.com

Presto pdf.

Running locally

The app is setup to use rails-root/bin/wkhtmltopdf-amd64 in production via this initializer code. This setting is overridden in development to look for /usr/local/bin/wkhtmltopdf in development mode (via this after_initialize block). If you want to run in development mode and are on an amd64 architecture you can just delete the after_initialize block. Otherwise, you'll probably want to grab wkhtmltopdf and update the after_initialize path as appropriate.

Asset Paths

Due to how wicked_pdf invokes wkhtmltopdf (the html file is supplied via stdin rather than as a url) all asset urls need to be absolute file paths rather than relative urls. For Rails usage, we can use ActionController::Base.asset_host to switch the path when the request format is pdf. (see here). We also need to extract any urls out of static stylesheets and put them into Rails templates instead so that the path can be swapped out to a file path when necessary. Example:

<style type="text/css" media="screen">
  #menu a {
    background: url(<%= image_path('menu.gif')%>) no-repeat;
  }
</style>

wkhtmltopdf version

Currently includes wkhtmltopdf version 0.9.9 static amd64 (works on heroku).

heroku-pdf's People

Watchers

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