Basic Example

suggest change

Add 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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents