Open mail2sanand opened 6 years ago
This does appear to be a bug in the main prawn
gem. I had custom fonts working in tables in prawn (2.1.0) but once I upgraded to prawn (2.2.2), I started to get the same crash:
Your document includes text that's not compatible with the Windows-1252 character set. If you need full UTF-8 support, use TTF fonts instead of PDF's built-in fonts.
I came up with the following hacky workaround that appears to be ok for now.
old (working on 2.1.0):
attentions = [["\uF003"]]
pdf.make_table attentions, cell_style: {
font: 'Font Awesome',
}
new (working on 2.2.2):
attentions = [["<font name='Font Awesome'>\uF003</font>"]]
pdf.make_table attentions, cell_style: {
font: 'Font Awesome',
inline_format: true,
}
Hi I am trying to display some up(HTML codes: ↑), down(HTML codes: ↓) and other special characters in Prawn PDF.
Some articles had suggested using UTF-8 codes for these special characters. So, started using the ttf fonts instead of the default afm fonts.
I was able to display them with normal text, by using ttf fonts. but when it to tables, it is not working.
Here is what I had done .
Registering of a new font family
Using this font in text is working fine.
Using the new ttf font in table
Options Tried :
table patient_cmc_details, :cell_style => {:font => "open-sans-ttf", :inline_format => true,:height => 20, :size => 10}
table patient_cmc_details, :cell_style => {:font => "#{Rails.root.join("app/assets/header/fonts/OpenSans-Regular.ttf")}", :inline_format => true,:height => 20, :size => 10}
patient_cmc_details = ([ [{:content => " CC : # \u2191 ",:font => "#{Rails.root.join("app/assets/header/fonts/OpenSans-Regular.ttf")}", :border_width => 0}]])
Error Reported
I happen to google for some help but not helpful. Can someone suggest a work-around
Anand