4

有没有办法用 PDFKit 和自定义字体打印 pdf?

在CSS中我有:

 @font-face {
font-family: 'ChaparralProRegular';
src: url("path_to_font/chaparralpro-regular-webfont.eot");
src: url("path_to_font/chaparralpro-regular-webfont.eot?#iefix") format("embedded-opentype"),
url("path_to_font/chaparralpro-regular-webfont.woff") format("woff"),
url("path_to_font/chaparralpro-regular-webfont.ttf")  format("truetype"),
url("path_to_font/chaparralpro-regular-webfont.svg#ChaparralProRegular") format("svg");

上面的代码在呈现为 html 但使用 PDFKit 使用标准字体打印到 pdf 时工作正常。有什么线索吗?

4

1 回答 1

1

我猜你的 pdfkit 只是找不到你的字体文件在哪里。我对pdf中的图像有同样的问题。尝试用本地文件路径替换字体文件的所有 url:

url("#{Rails.root}/path_to_font/chaparralpro-regular-webfont.eot");
于 2012-11-03T20:31:56.257 回答