我正试图用Prawn生成PDF。 在我的PDF模板中,我有带单元格的表格。 在其中一个单元格中,我有一个电子邮件地址,我想让电子邮件链接到 "mailto "链接。
cell_email = pdf.make_cell(:content => booking.user_email, :border_width => 0)
我想让电子邮件链接到 "mailto "链接。 我知道我可以像这样链接。
pdf.formatted_text([{:text => booking.user_email, :link => "mailto: #{booking.user_email}"}])
但是把这两行结合起来(把格式化的文本作为内容)就不行了。
cell_email = pdf.make_cell(:content => pdf.formatted_text([{:text => booking.user_email, :link => "mailto: #{booking.user_email}"}]), :border_width => 0)
任何想法,我可以克服这个问题(在表格单元格内创建一个电子邮件链接)?
亲切的问候和非常感谢
你可以指定 inline_format
的单元格,并自己创建链接。
cell_email = pdf.make_cell(
:content => "<link href='mailto:#{booking.user_email}'>#{booking.user_email}</link>",
:inline_format => true
)
你可以指定 inline_format
为整个餐桌,也。
table data, :cell_style => { :inline_format => true }
大虾的 inline_format
支持 <b>
, <i>
, <u>
, <strikethrough>
, <sub>
, <sup>
, <font>
, <color>
和 <link>
.
以下是链接的下划线,并赋予其蓝色。
link = make_cell(content: "<color rgb='0000FF'> <u> <link href='https://stackoverflow.com/questions/11390505/prawn-links-inside-table-cells'> #{booking.user_email} </link></u> </color>", inline_format: true)
data = [[link]]
table(data,:header => true, :row_colors =>["F0F0F0","FFFFCC"]) do
end