ABCpdf 上的符号字体
我正在使用 ABCpdf.net 组件将 HTML 转换为 PDF。一些 HTML 使用符号字体来显示某些字符。不幸的是,我们正在使用来自第三方的 HTML,并且无法更改。
我的开发环境可以正确显示字体,但我的生产环境却不能。尽管已经安装了字体,但它的行为就好像未安装字体一样。如果我在生产环境中的 Internet Explorer 中呈现相同的 HTML,它会显示得很好。
我尝试将字体嵌入为 .eot 并在标题中提供 @font-face 样式。我尝试过使用 TheDoc.AddFont('Symbol')。有什么建议吗?
产品:ABCpdf .NET 7 x64
生产操作系统:Windows Server 2003 x64、IE8
开发操作系统:Win7 x64、IE8
I'm using the ABCpdf.net component to convert HTML to PDF. Some of the HTML uses the Symbol font to display certain characters. Unfortunately, we are consuming the HTML from a third-party, and it cannot be changed.
My development environment displays the font correctly, but my production environment will not. It acts as though the font is not installed, even though it is. If I render the same HTML in Internet Explorer on the production environment, it displays just fine.
I have tried embedding the font as an .eot and providing a @font-face style in the header. I have tried using TheDoc.AddFont('Symbol'). Any suggestions?
Product: ABCpdf .NET 7 x64
Production OS: Windows Server 2003 x64, IE8
Development OS: Win7 x64, IE8
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
WebSuperGoo 支持团队做出了修复:设置与字体相关的 HtmlOptions。我设置了这些选项,它解决了问题。耶!
编辑:正如我在下面的评论中提到的,实现这一目的的选项是 FontProtection = false。
The WebSuperGoo support team responded with the fix: setting font-related HtmlOptions. I set these options, and it fixed the issue. Yay!
Edit: As I mention in the comment below, the option that did the trick was FontProtection = false.
尝试重新启动服务器。
我在 ABCPdf 上的字体上也遇到过类似的问题。尽管字体已明确安装,但由于某种原因,ABDPdf 直到计算机重新启动后才拾取它们。
可能有一些非重新启动的方法可以实现同样的事情,但这需要了解问题是什么!如果很容易,只需尝试重新启动即可。
Try restarting the server.
I've had a similar issue with fonts on ABCPdf. Although the fonts were clearly installed, for some reason, ABDPdf didn't pick them up until the machine has been restarted.
There may be some non restart way of achieving the same thing, but that would entail understanding what the problem is! If it's easy, just try restarting.
虽然我说 Doc.HtmlOptions 就是答案,但事实证明它完全是另一回事。由于字体粗细不正常(即粗体),符号未显示。没有包含这些字符的粗体子集。 IE 足够聪明,可以忽略粗体部分,但 PDF 则相当挑剔。它找不到该字符,因此什么也没有显示。
真正的解决方案是梳理 HTML 并确保所有符号都被带有
font-weight: normal !important
的span
包围。这也许是一个不太优雅的解决方案,但它很有效。唯一仍然随机拒绝显示的符号是角度符号 (∠
)。为此,我用图像替换了它。我还是不明白为什么它不会出现。Although I said that the Doc.HtmlOptions was the answer, it turned out that it was something else entirely. The symbols did not show up because the font-weight was not normal (i.e., it was bold). There is no bold subset that contains these characters. IE is smart enough to ignore the bold part, but PDF is rather finicky. It cannot find the character, so it just shows nothing.
The real solution was to comb through the HTML and ensure that all symbols were surrounded by a
span
withfont-weight: normal !important
. It is perhaps a less elegant solution, but it is effective. The only symbol that still randomly refused to show up is the angle symbol (∠
). For this, I replaced it with an image. I still can't figure out why it won't appear.