Skip to content

Instantly share code, notes, and snippets.

@Hirurg103
Created September 26, 2013 12:56
Show Gist options
  • Save Hirurg103/6713778 to your computer and use it in GitHub Desktop.
Save Hirurg103/6713778 to your computer and use it in GitHub Desktop.
class WidgetsController < ApplicationController
class TestDocument < Prawn::Document
def to_pdf
text "Hello World!"
render
end
end
def index
output = TestDocument.new.to_pdf
respond_to do |format|
format.pdf {
send_data output, filename: "hello.pdf", type: "application/pdf", disposition: "inline"
}
format.html {
render text: "<h1>Use .pdf</h1>".html_safe
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment