Prawn - 在表格单元格中添加图像和文本

Raj*_*tan 3 ruby-on-rails prawn ruby-2.0

是否可以使用宝石虾将图像文本一起嵌入表格单元格中?

我正在使用 gem "prawn", "~> 0.13.2"

我只能嵌入图像或文本.但是,不是两个.请帮忙.

Rails版本:3.2.13和Ruby 2.0.0

Мал*_*евъ 6

以下是手册中有关如何将图像和文本插入PDF文档的代码:

text "Scale by setting only the width"
image "#{Prawn::DATADIR}/images/pigs.jpg", :width => 150
move_down 20

text "Scale by setting only the height"
image "#{Prawn::DATADIR}/images/pigs.jpg", :height => 100
move_down 20

text "Stretch to fit the width and height provided"
image "#{Prawn::DATADIR}/images/pigs.jpg", :width => 500, :height => 100
Run Code Online (Sandbox Code Playgroud)

以下是手册中有关如何将图像和文本插入PDF文档的表格单元格的代码:

cell_1 = make_cell(:content => "this row content comes directly ")
cell_2 = make_cell(:content => "from cell objects")
two_dimensional_array = [ ["..."], ["subtable from an array"], ["..."] ]
my_table = make_table([ ["..."], ["subtable from another table"], ["..."] ])
image_path = "#{Prawn::DATADIR}/images/stef.jpg"

table([ ["just a regular row", "", "", "blah blah blah"],
    [cell_1, cell_2, "", ""],
    ["", "", two_dimensional_array, ""],
    ["just another regular row", "", "", ""],
    [{:image => image_path}, "", my_table, ""]])
Run Code Online (Sandbox Code Playgroud)

有关自定义表格单元格图像的更多信息:请查看Prawn文档