1
votes

I'm using prawn to generate pdfs.
In one of my tables, I would like to insert a checkmark via html code (ascii) -> [☒ or ☐]. I tried to use HTMLEntities gem but doesn't work in views, just on IRB. And html_safe either. On the pdf, there is just a '_' character (underscore).
I'm am in utf-8.
Any ideas why? Is there another solution?

1

1 Answers

2
votes

This is because your font doesn't include these glyphs. Use a font that does:

require 'prawn'
Prawn::Document.generate('checkmarks.pdf') do |pdf| 
  pdf.font("/Library/Fonts/Arial Unicode.ttf") # adjust font path
  pdf.text("☒ ☐")
end