如何让CSS字体与此Grails PDF渲染插件一起使用? [英] How do I get the CSS fonts to work with this Grails PDF rendering plug-in?
问题描述
我使用Grails渲染插件来生成PDF。
我想用我的PDF包含CSS来很好地渲染它。我在渲染插件网站上找到了一个示例, p>
我将CSS放在了打印介质中,以便它可以用于PDF,但这对我不起作用。我也不知道如何将字体从Arial更改为另一种字体。有人可以向我解释这一点吗?
插件使用带有CSS的Arial字体:
@ font-face {
src:url(path / to / arial.ttf);
-fs-pdf-font-embed:embed;
-fs-pdf-font-encoding:cp1250;
}
body {
font-family:Arial Unicode MS,Arial,sans-serif;
您需要arialuni.ttf而不是只需arial.ttf在这里下载: http ://www.findthatfonts.com/search-2683324-hTTF/fonts-download-search-engine-ARIALUNI.ttf.htm
然后 p>
你必须给你的@ font-face一个这样的字体名称:
@ font-face {
font-family:Font-Name;
src:url(path / to / font.ttf); //你必须将你的font.ttf文件添加到像assets / css / fonts之类的文件夹中的服务器上。
-fs-pdf-font-embed:embed;
-fs-pdf-font-encoding:cp1250;
}
body {
font-family:Font-Name,Arial,sans-serif; //你在@ font-face中调用了你的字体Font-Name,所以现在你可以在你的css中的其他地方使用它作为Font-Name。
}
否则你的arialuni.ttf没有名字,所以你不能使用它其他div在你的CSS。
I am using a Grails rendering plugin to generate PDF.
I want to include CSS with my PDF to render it nicely. I found an example on the rendering plugin website
I put the CSS below in print media so that it works for PDF, but this does not work for me. I also do not know how to change the font from Arial to another font. Can someone explain this to me?
The plugin uses Arial font with this CSS:
@font-face {
src: url(path/to/arial.ttf);
-fs-pdf-font-embed: embed;
-fs-pdf-font-encoding: cp1250;
}
body {
font-family: "Arial Unicode MS", Arial, sans-serif;
}
You need arialuni.ttf not just arial.ttf download it here: http://www.findthatfonts.com/search-2683324-hTTF/fonts-download-search-engine-ARIALUNI.ttf.htm
Then
You have to give your @font-face a font-family name like this:
@font-face {
font-family: "Font-Name";
src: url(path/to/font.ttf); // you have to add your font.ttf file to the server in a folder like assets/css/fonts or something.
-fs-pdf-font-embed: embed;
-fs-pdf-font-encoding: cp1250;
}
body {
font-family: "Font-Name", Arial, sans-serif; // you called your font Font-Name in the @font-face so now you can use it as Font-Name everywhere else in you css.
}
Otherwise your arialuni.ttf has no name so you can't use it in other divs in your css.
这篇关于如何让CSS字体与此Grails PDF渲染插件一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!