Basic Example
suggest changeYou need to add Gem and PDF MIME:Type inside mime_types.rb as we need to notify rails about PDF mime type.
After that we can generate Pdf with Prawn in following basic 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