README.md in wicked_pdf-0.7.2 vs README.md in wicked_pdf-0.7.3
- old
+ new
@@ -1,10 +1,10 @@
# Wicked PDF
## A PDF generation plugin for Ruby on Rails
-Wicked PDF uses the shell utility [wkhtmltopdf](http://code.google.com/p/wkhtmltopdf/) to serve a PDF file to a user from HTML. In other words, rather than dealing with a PDF generation DSL of some sort, you simply write an HTML view as you would normally, and let Wicked take care of the hard stuff.
+Wicked PDF uses the shell utility [wkhtmltopdf](http://code.google.com/p/wkhtmltopdf/) to serve a PDF file to a user from HTML. In other words, rather than dealing with a PDF generation DSL of some sort, you simply write an HTML view as you would normally, then let Wicked take care of the hard stuff.
_Wicked PDF has been verified to work on Ruby 1.8.7 and 1.9.2; Rails 2 and Rails 3_
### Installation
@@ -16,10 +16,15 @@
Next:
script/plugin install git://github.com/mileszs/wicked_pdf.git
script/generate wicked_pdf
+
+or add this to your Gemfile:
+
+ gem 'wicked_pdf'
+
### Basic Usage
class ThingsController < ApplicationController
def show
respond_to do |format|
@@ -38,11 +43,11 @@
respond_to do |format|
format.html
format.pdf do
render :pdf => 'file_name',
:template => 'things/show.pdf.erb',
- :layout => 'pdf.html', # use 'pdf.html' for a pfd.html.erb file
+ :layout => 'pdf.html', # use 'pdf.html' for a pdf.html.erb file
:wkhtmltopdf => '/usr/local/bin/wkhtmltopdf', # path to binary
:show_as_html => params[:debug].present?, # allow debuging based on url param
:orientation => 'Landscape', # default Portrait
:page_size => 'A4, Letter, ...', # default A4
:save_to_file => Rails.root.join('pdfs', "#{filename}.pdf"),
@@ -53,10 +58,12 @@
:password => 'TEXT',
:cover => 'URL',
:dpi => 'dpi',
:encoding => 'TEXT',
:user_style_sheet => 'URL',
+ :cookie => ['_session_id SESSION_ID'], # could be an array or a single string in a 'name value' format
+ :post => ['query QUERY_PARAM'], # could be an array or a single string in a 'name value' format
:redirect_delay => NUMBER,
:zoom => FLOAT,
:page_offset => NUMBER,
:book => true,
:default_header => true,
@@ -72,21 +79,23 @@
:no_background => true,
:margin => {:top => SIZE, # default 10 (mm)
:bottom => SIZE,
:left => SIZE,
:right => SIZE},
- :header => {:html => { :template => 'users/header.pdf.erb', # use :template OR :url
+ :header => {:html => { :template => 'users/header.pdf.erb', # use :template OR :url
+ :layout => 'pdf_plain.html', # optional, use 'pdf_plain.html' for a pdf_plain.html.erb file, defaults to main layout
:url => 'www.example.com',
:locals => { :foo => @bar }},
:center => 'TEXT',
:font_name => 'NAME',
:font_size => SIZE,
:left => 'TEXT',
:right => 'TEXT',
:spacing => REAL,
:line => true},
:footer => {:html => { :template => 'shared/footer.pdf.erb', # use :template OR :url
+ :layout => 'pdf_plain.html', # optional, use 'pdf_plain.html' for a pdf_plain.html.erb file, defaults to main layout
:url => 'www.example.com',
:locals => { :foo => @bar }},
:center => 'TEXT',
:font_name => 'NAME',
:font_size => SIZE,
@@ -144,11 +153,11 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
### Styles
-You must define absolute path's to CSS files, images, and javascripts; the best option is to use the *wicked_pdf_stylesheet_link_tag*, *wicked_pdf_image_tag*, and *wicked_pdf_javascript_include_tag* helpers.
+You must define absolute paths to CSS files, images, and javascripts; the best option is to use the *wicked_pdf_stylesheet_link_tag*, *wicked_pdf_image_tag*, and *wicked_pdf_javascript_include_tag* helpers.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
@@ -166,11 +175,11 @@
</body>
</html>
### Page Numbering
-A bit of javascript can help you number your pages, create a template or header/footer file with this:
+A bit of javascript can help you number your pages. Create a template or header/footer file with this:
<html>
<head>
<script>
function number_pages() {
@@ -200,10 +209,12 @@
You can put your default configuration, applied to all pdf's at "wicked_pdf.rb" initializer.
### Further Reading
-Andreas Happe's post [Generating PDFs from Ruby on Rails](http://snikt.net/index.php/2010/03/03/generating-pdfs-from-ruby-on-rails)
+Andreas Happe's post [Generating PDFs from Ruby on Rails](http://starseeders.net/generating-pdfs-from-ruby-on-rails/)
+
+StackOverflow [questions with the tag "wicked-pdf"](http://stackoverflow.com/questions/tagged/wicked-pdf)
### Debugging
Now you can use a debug param on the URL that shows you the content of the pdf in plain html to design it faster.