我正在使用wicked_pdf和rails 3.2.11以及ruby 1.9.3从HTML生成PDF并部署到Heroku.
我的pdf.css.scss.erb:
<% app_fullhost = Constants["app_fullhost"] %>
@font-face {
font-family:'DosisMedium'; font-style:normal; font-weight:500;
src: url(<%=app_fullhost%>/app/font/dosis/Dosis-Medium.ttf) format('woff');
}
*, body {
font-family: "DosisLight", 'Times New Roman', 'Arial', sans-serif;
}
Run Code Online (Sandbox Code Playgroud)
app_fullhost在开发或生产中,确切的主机在哪里.
我的pdf布局包括:
%html{:lang => I18n.locale}
%head
%meta{:charset => "utf-8"}
%title= content_for?(:title) ? yield(:title) : Settings.app_name
= wicked_pdf_stylesheet_link_tag "pdf"
Run Code Online (Sandbox Code Playgroud)
在production.rb我有
config.assets.precompile +=%w(pdf.css)
Run Code Online (Sandbox Code Playgroud)
这在开发中没有问题,但在Heroku上,pdf文件不会加载所需的字体.我也尝试过不同的解决方案,比如在production.rb中添加这些解决方案:
config.assets.paths << "#{Rails.root}/app/assets/fonts"
config.assets.precompile += %w(*.svg *.eot *.woff *.ttf)
config.assets.precompile += %w(.svg .eot .woff .ttf)
Run Code Online (Sandbox Code Playgroud)
我也尝试改变(在pdf.css.scss.erb中):
@font-face {
font-family:'Dosis'; font-style:normal; font-weight:500;
src: url('Dosis-Medium.ttf') format('woff');
}
Run Code Online (Sandbox Code Playgroud)
要么 …