我想要做的是使用蝦生成一個PDF,同時具有一些語言特定的字符。如何更改對蝦的字體
而作爲一個結果,我發現了以下錯誤:
raise Prawn::Errors::IncompatibleStringEncoding,
"Your document includes text that's not compatible with the Windows-1252 character set.\n" \
"If you need full UTF-8 support, use TTF fonts instead of PDF's built-in fonts\n."
所以,我想通過這樣改變字體:
# app/models/prawn/change_font_decorator.rb
Prawn::Document.generate("output.pdf") do
font_families.update("Arial" => {
:normal => Rails.root.join("app/assets/fonts/OpenSans-Regular.ttf"),
:italic => Rails.root.join("app/assets/fonts/OpenSans-Regular.ttf"),
:bold => Rails.root.join("app/assets/fonts/OpenSans-Regular.ttf"),
:bold_italic => Rails.root.join("app/assets/fonts/OpenSans-Regular.ttf")
})
font "Arial"
end
然而,我得到了同樣的錯誤時,試圖生成一個PDF文件。
關於如何解決這個問題的任何想法?
如何在表格單元中實現? –