Question

est ce que j'ai jusqu'à présent, mais je dois définir les marges:

def send_fax 
    contact = Contact.find_by_id(self.contact_id)

    pdf = Prawn::Document.new
    pdf.font "Times-Roman"
    pdf.move_down(20)
    pdf.text "ATTN: #{contact.first_name} #{contact.last_name}", :size => , :style => :bold
    pdf.text "RE: #{self.subject}"
    pdf.move_down(20)

    pdf.text "#{self.body}"

    OutboundMailer.deliver_fax_email(contact, self, pdf)

  end
Était-ce utile?

La solution

Prawn::Document.new( :margin => [0,0,0,0] )

:margin:    Sets the margin on all sides in points [0.5 inch]
:left_margin:   Sets the left margin in points [0.5 inch]
:right_margin:  Sets the right margin in points [0.5 inch]
:top_margin:    Sets the top margin in points [0.5 inch]
:bottom_margin: Sets the bottom margin in points [0.5 inch]

http://rdoc.info/github/sandal/prawn/master/ Prawn / document

Autres conseils

Il suffit d'ajouter au panthéon de la connaissance, mais dans le cas où vous êtes venu ici à la recherche de le faire en utilisant la pierre précieuse Label Prawn, vous ne pouvez pas définir la marge du document de cette façon. Vous aurez à faire un travail autour. Voici un extrait rapide et flexible pour la création d'un cadre de sélection avec un tampon uniforme qui se trouve à l'intérieur du cadre de sélection de document.

pad = 5

pdf.bounding_box([pad, pdf.bounds.height - pad], :width => pdf.bounds.width - (pad * 2), :height => pdf.bounds.height - (pad * 2)) do
    #Draw all your content in this block and it will be padded uniformly by 5
end

Retirez le pdf de .bounding_box et .bounds si vous utilisez une version langoustine implicite.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top