Tim*_* T. 16 pdf-generation ruby-on-rails prawn
这是我到目前为止,但我需要设置边距:
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
Run Code Online (Sandbox Code Playgroud)
Geo*_*son 24
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]
Run Code Online (Sandbox Code Playgroud)
http://rdoc.info/github/sandal/prawn/master/Prawn/Document
只是在这里添加知识万神殿,但如果您来这里是想使用 Prawn Label gem 来完成此操作,则无法以这种方式设置文档边距。你必须解决这个问题。这是一个快速灵活的代码片段,用于创建带有位于文档边界框内的统一垫的边界框。
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
Run Code Online (Sandbox Code Playgroud)
如果您使用的是 Prawn 的隐式版本,请从 .bounding_box 和 .bounds 中删除 pdf。
| 归档时间: |
|
| 查看次数: |
12119 次 |
| 最近记录: |