简体   繁体   English

ABCPDF-CSS嵌入式@Fontface无法正常工作

[英]ABCPDF - CSS Embedded @Fontface not working

I'm looking for a definitive answer to this question, as I can only find scattered pieces of information. 我正在寻找这个问题的明确答案,因为我只能找到零散的信息。

In our site css we use an embedded webfont using @fontface. 在我们的网站CSS中,我们使用@fontface嵌入的webfont。 When we render a pdf of pages using ABCPDF, the font does not show. 当我们使用ABCPDF渲染页面pdf时,字体不显示。 We are using both addImageurl to get website pages, and addHtml to add our own personalized front cover. 我们都使用addImageurl获取网站页面,并使用addHtml添加我们自己的个性化封面。

We are using the msHTML engine. 我们正在使用msHTML引擎。

Has anyone had experience of using non-system/standard fonts, and using embedded web fonts? 有没有人有使用非系统/标准字体和嵌入式Web字体的经验?

Thanks 谢谢

ABC doesn't support @fontface. ABC不支持@fontface。

However you can use custom fonts if you know what the font is beforehand (if the content is from your own server) when using addImageHTML(). 但是,如果在使用addImageHTML()时事先知道字体是什么(如果内容来自您自己的服务器),则可以使用自定义字体。

All you need to do is install the font on your server (eg here I'm using OpenSans), and then reference it in your CSS like so: 您需要做的就是在服务器上安装字体(例如,这里我使用的是OpenSans),然后像这样在CSS中引用它:

@font-face {
    font-family: 'open_sansregular';
    src: url('../fonts/OpenSans-Regular-webfont.eot');
    src: url('../fonts/OpenSans-Regular-webfont.eot?#iefix') format('embedded-opentype'),
         url('../fonts/OpenSans-Regular-webfont.woff') format('woff'),
         url('../fonts/OpenSans-Regular-webfont.ttf') format('truetype'),
         url('../fonts/OpenSans-Regular-webfont.svg#open_sansregular') format('svg');
}

body
{
    font-family: Open Sans, 'open_sansregular', sans-serif;
}

The key here is the: 这里的关键是:

    font-family: Open Sans 

part. 部分。 This will try to reference a font named "Open Sans" that is on the local computer than renders the HTML. 这将尝试引用本地计算机上的名为“ Open Sans”的字体,而不是呈现HTML的字体。 AbcPDF will pick it up and use it (I've done it myself). AbcPDF将选择并使用它(我自己做了)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM