更改桌子大小的对虾 [英] Change Table Size Prawn

查看:30
本文介绍了更改桌子大小的对虾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在用对虾做一份Ruby​​报告!如何更改表格的大小?

编码:

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

推荐答案

您可以将选项哈希作为参数传递给指定列宽或宽度的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

这篇关于更改桌子大小的对虾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆