大家好,我正在使用虾做红宝石报告!如何更改表的大小?
代码:
require "prawn"
require "prawn/table"
logo=Dir.pwd+"/logo.jpg"
arr = ['a', 'aa', 'aaa', 'ddd', 'eee', 'fff']
arr2 = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff']
arr3 = ['a', 'b', 'c', 'd', 'e', 'f']
Prawn::Document.generate("rapportino.pdf") do
move_down 10
image logo,:width=>540,:height=>60
move_down 30
text "Ragione Sociale: "+ARGV[0]
move_down 30
text "Nome Cantiere: "+ARGV[1]
move_down 30
text "Note: "+ARGV[2]
move_down 30
table([
["Articolo - Risorsa", "Descrizione", "Quantita"],
*[arr, arr2, arr3]
.transpose
])
end
答案 0 :(得分:0)
您可以将选项哈希作为参数传递给table()
,指定列宽或宽度。
options = {column_widths:{ 0 => 125, 1 => 100 }, width: 225}
在你的例子中:
options = {column_widths:{ 0 => 125, 1 => 100 }, width: 225}
arr = ['a', 'aa', 'aaa', 'ddd', 'eee', 'fff']
arr2 = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff']
arr3 = ['a', 'b', 'c', 'd', 'e', 'f']
Prawn::Document.generate("rapportino.pdf") do
move_down 10
image logo,:width=>540,:height=>60
move_down 30
text "Ragione Sociale: "+ARGV[0]
move_down 30
text "Nome Cantiere: "+ARGV[1]
move_down 30
text "Note: "+ARGV[2]
move_down 30
table([
["Articolo - Risorsa", "Descrizione", "Quantita"],
*[arr, arr2, arr3]
.transpose
],options)
end