2017-06-22 25 views
0

我使用蝦實現了pdf生成,這對我的測試服務器工作沒有任何問題。 部署和測試功能後,我得到了以下錯誤消息對蝦字體家族更新結果爲空pdf

Your document includes text that's not compatible with the Windows-1252 character set. 

如果您需要完整的UTF-8支持,使用TTF字體代替PDF的內置字體。

所以我增加了一個TTF字庫,並添加該代碼大蝦

p.font_families.update("DejaVuSerif" => { 
     :normal => "#{Rails.root}/path/to/fonts/DejaVuSerif.ttf", 
:bold => "#{Rails.root}/path/to/fonts/DejaVuSerif-Bold.ttf"   
    }) 

p.font "DejaVuSerif" 

現在我沒有得到任何錯誤消息,但它會導致空的PDF並沒有什麼錯誤日誌中也是如此。

任何人的任何想法?

回答

0

我用蝦與外部字體

以下是pdf.rb類代碼

class DataPDF < Prawn::Document 
    def initialize 
     font Rails.root.join("app/assets/fonts/DejaVuSerif.ttf") 
    end 
end 

,並確保對文件名大/小寫一樣的是文件夾

物理文件