Chr*_*ris 7 ruby pdf pdf-generation prawn
我想用prawn pdf在ruby中生成一个简单的表.
我需要一个单元格中的一些文本是粗体,有些不是粗体.例如:
现在,按照一些示例,我使用以下代码进行基本表格渲染:
pdf.table([
["1. Row example text", "433"],
["2. Row example text", "2343"],
["3. Row example text", "342"],
["4. Row example text", "36"]], :width => 500, :cell_style => {
:font_style => :bold})
Run Code Online (Sandbox Code Playgroud)
但我完全没有办法用更多格式将更多文本插入第一个单元格.(在这种情况下,我希望它是无键的)
有谁知道如何做到这一点?
谢谢你的帮助
sai*_*ala 21
Prawn::Document.generate("test.pdf") do |pdf|
table_data = [[Prawn::Table::Cell::Text.new( pdf, [0,0], :content => "<b>1. Row example text</b> \n\nExample Text Not Bolded", :inline_format => true), "433"],
[Prawn::Table::Cell::Text.new( pdf, [0,0], :content => "<b>2. Row example text</b>", :inline_format => true), "2343"],
[Prawn::Table::Cell::Text.new( pdf, [0,0], :content => "<b>3. Row example text</b>", :inline_format => true), "342"],
[Prawn::Table::Cell::Text.new( pdf, [0,0], :content => "<b>4. Row example text</b>", :inline_format => true), "36"]]
pdf.table(table_data,:width => 500)
end
Run Code Online (Sandbox Code Playgroud)
你也可以
Prawn::Document.generate("test.pdf") do |pdf|
table_data = [["<b>1. Row example text</b>\n\nExample Text Not Bolded", "<b>433<b>"],
["<b>2. Row example text</b>", "<b>2343</b>"],
["<i>3. Row example text</i>", "<i>342</i>"],
["<b>4. Row example text</b>", "<sub>36</sub>"]]
pdf.table(table_data, :width => 500, :cell_style => { :inline_format => true })
end
Run Code Online (Sandbox Code Playgroud)
Prawn的inline_format支持 <b>, <i>, <u>, <strikethrough>, <sub>, <sup>, <font>, <color> and <link>
归档时间: |
|
查看次数: |
7535 次 |
最近记录: |