gpt4 book ai didi

ruby-on-rails - ruby Prawn gem ,餐 table 位置

转载 作者:行者123 更新时间:2023-12-03 18:42:46 26 4
gpt4 key购买 nike

使用prawn gem我在pdf文件中显示表格..现在我想设置表格的位置,请指导我如何处理这个..

我使用以下代码生成pdf报告,

pdftable = Prawn::Document.new

pdftable.table([["Name","Login","Email"]],
:column_widths => {0 => 80, 1 => 80, 2 => 80, 3 => 80}, :row_colors => ["d5d5d5"])

@users.each do|u|
pdftable.table([["#{u.name}","#{u.login}","#{u.email}"]],
:column_widths => {0 => 80, 1 => 80, 2 => 80, 3 => 80 }, :row_colors => ["ffffff"])

谢谢

最佳答案

您可以将函数 indent() 与函数 move_down 和 move_up 结合使用,
因此,例如在位置(50,20)(相对于您的光标位置)设置表将如下所示:

move_down 20
indent(50) do #this is x coordinate
pdftable.table([["Name","Login","Email"]],
:column_widths => {0 => 80, 1 => 80, 2 => 80, 3 => 80}, :row_colors => ["d5d5d5"])

@users.each do|u|
pdftable.table([["#{u.name}","#{u.login}","#{u.email}"]],
:column_widths => {0 => 80, 1 => 80, 2 => 80, 3 => 80 }, :row_colors => ["ffffff"])
end

`

关于ruby-on-rails - ruby Prawn gem ,餐 table 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7578678/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com