Basic Example
suggest changeAdd the Prawn gem, and register the PDF MIME type in config/initializers/mime_types.rb, so Rails recognizes format.pdf. Prawn can then build a PDF in any of these ways:
This is the basic assignment
pdf = Prawn::Document.new
pdf.text "Hello World"
pdf.render_file "assignment.pdf"
We can do it with Implicit Block
Prawn::Document.generate("implicit.pdf") do
text "Hello World"
end
With Explicit Block
Prawn::Document.generate("explicit.pdf") do |pdf|
pdf.text "Hello World"
end
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents