css - @font-face 不适用于 wkhtmltopdf

标签 css ubuntu ruby-on-rails-3.2 font-face wkhtmltopdf

**My code**
@font-face {
font-family: 'certificateitalic';
src: url('/webfontkit-20140113-085051/certificateitalic-webfont.eot');
src: url('/webfontkit-20140113-085051/certificateitalic-webfont.eot?#iefix') format('embedded-opentype'),
     url('/webfontkit-20140113-085051/certificateitalic-webfont.woff') format('woff'),
     url('/webfontkit-20140113-085051/certificateitalic-webfont.ttf') format('truetype'),
     url('/webfontkit-20140113-085051/certificateitalic-webfont.svg#certificateitalic') format('svg');
font-weight: normal;
font-style: normal;

这是generatecertificate.html.erb中使用的代码

最佳答案

也许不仅仅是字体,请检查您在创建 pdf 时是否收到了所需的所有资源。

上次我检查时,我不得不使用 wkhtmltopdf 提供的一个名为 wkhtmltopdf_stylesheet_link_tag 的助手,而不是您应该在 View /部分/布局中使用的经典 stylesheet_link_tag。

编辑:实际上,我使用的是 wicked_pdf gem(https://github.com/mileszs/wicked_pdf),那里有像 wicked_pdf_stylessset_link_tag 这样的助手,并解决了 wkhtmltopdf 配置的大部分配置。

如果您按照那里的说明进行配置,并且您的字体在网页上工作正常,那么在生成 pdf 时应该没有任何问题。

关于css - @font-face 不适用于 wkhtmltopdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21130436/

相关文章:

ruby-on-rails - 403 Forbidden when using nginx + rails + Passenger

ubuntu - ffmpeg avcodec_open2() 仅在 ubuntu 中返回错误 -22

linux - Beaglebone Black ubuntu 编译驱动

ruby - 如何使用有效? rails 3中数组的方法

ruby - 未初始化的常量 StoreController::Yajl Rails 应用程序

html - 显示/ float ,样式列表

javascript - 深色模式开关

html - 可以在 HTML 元素上声明 CSS 伪类吗?

html - 流体布局 : aside element larger than main element

ruby-on-rails - 尝试执行从 "rails"开始的任何命令会产生 "Could not locate Gemfile"