简体   繁体   English

如何在虾中心表?

[英]How to center table in prawn?

I have created a table in prawn and wanted to pass the :position option by whih is also documented in the manual but it throws off an Method_missing error. 我已经在大虾中创建了一个表,并希望通过:position选项,也可以在手册中记录,但它会抛出Method_missing错误。 It seems like this parameter doesnt exist anymore. 看起来这个参数不再存在了。 How can I center a table in prawn? 我怎样才能在虾中居中?

I ran into the same error. 我遇到了同样的错误。 Installing from master on Github fixed the issue. 在Github上从master安装修复了这个问题。

# Gemfile
gem 'prawn', git: 'https://github.com/prawnpdf/prawn.git'

Issue thread on Github 在Github上发布线程

Hope this helps 希望这可以帮助

pdf.table tablename,
    :border_width => 0,
    :font_size => 11,
    :position => :center

whether the PDF generation is from a declared class or within the controller you need to add the following line to your Gemfile 无论PDF生成是来自声明的类还是控制器内,您都需要将以下行添加到Gemfile中

gem 'prawn-table', '~> 0.2.1'

At the time of writing that is the gem version, this will give you access to the table methods such as position 在撰写宝石版本时,这将使您可以访问表格方法,例如位置

I used it in this example and it worked 我在这个例子中使用它并且它有效

def table_items(chart_data, doc)
  table = Prawn::Table.new(table_rows(chart_data), doc, {:header => true})
  table.row(0).font_style = :bold
  table.position = :center
  table.draw
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM