我正在使用蝦在Rails 3應用程序中生成PDF。蝦:在PDF中打印unicode字符串
是否可以在HTML視圖中打印一個Unicode字符串到PDF中?
例如,
<%= raw "unicode_for_ཀ" %>
在show.html.erb
導致字形&#x0F40;而
pdf.text raw "unicode_for_ཀ"
在show.pdf.prawn
結果字符串"unicode_for_ཀ"
在show.pdf.prawn
試圖在:
pdf.font "#{Prawn::BASEDIR}/data/fonts/TibMachUni-1.901b.ttf" do
pdf.text raw "unicode_for_ཀ"
end
和
pdf.font_families.update("TibMachUni" => {:normal => "#{Prawn::BASEDIR}/data/fonts/TibMachUni-1.901b.ttf" })
pdf.font("TibMachUni") do
pdf.text raw "unicode_for_ཀ"
end
這並沒有解決問題。
我真的不明白問題是什麼? – phoet 2012-02-10 21:02:49
我的問題是相應的字符串到Unicode字符串(例如\ x0F40)沒有顯示在我的pdf。它會簡單地轉換爲utf-8並顯示爲常規字符串(例如「\ x0F40」)。 – obj 2012-02-10 21:13:56