hcarreras hcarreras - 1 year ago 95
Ruby Question

Prawn: how to set document's printable dimensions

I'm generating a pdf with prawn. Basically, I generate the document and I fill it with some images.
The problem comes when I download the file and I try to print it. The dimensions are not set to the ones I previously specified.

pdf = Prawn::Document.new(page_size: "A3", margin: PAGE_MARGIN, page_layout: :landscape)

When I try to print it, the default page size is "A4" instead of "A3"
How can I solve this?
I tried to attach some metadata but it didn't work correctly.

Thanks in advance!

Answer Source

Using prawn 1.3.0:

require "prawn"

pdf = Prawn::Document.new(:page_size => 'A3')

pdf.text "Hello World!"


in terminal:

pdfinfo export.pdf


Creator:        Prawn
Producer:       Prawn
Tagged:         no
Form:           none
Pages:          1
Encrypted:      no
Page size:      841.89 x 1190.55 pts
Page rot:       0
File size:      842 bytes
Optimized:      no
PDF version:    1.3
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download