获取字体时 iTextSharp 崩溃并出现 StackOverflowException
当我尝试创建字体时,iTextSharp 真的非常不喜欢它:
FontFactory.GetFont(Font.HELVETICA, 12)
这给了我一个用户友好的 StackOverflowException
。所以我尝试了这个:
new Font(Font.HELVETICA, 12)
它做了同样的事情。尝试了 Font.TIMES,也得到了同样的结果。所以我尝试根据这个答案降低一点,这表明:
BaseFont bf = BaseFont.CreateFont(
HttpContext.Current.Server.MapPath("/path/to/times.ttf"),
BaseFont.IDENTITY_H,
BaseFont.EMBEDDED);
new Font(bf, 12);
再次,StackOverflowException
。虽然一致性很好,但我更希望图书馆允许我选择字体。
我确信我只是在某个地方出现了一些配置错误;但我不知道它可能是什么。
iTextSharp really, really doesn't like it when I try to create Fonts:
FontFactory.GetFont(Font.HELVETICA, 12)
This gives me a user-friendly StackOverflowException
. So I tried this:
new Font(Font.HELVETICA, 12)
which does the same thing. Tried Font.TIMES
, and got the same thing, too. So I tried dropping a bit lower based on this answer, which suggests the following:
BaseFont bf = BaseFont.CreateFont(
HttpContext.Current.Server.MapPath("/path/to/times.ttf"),
BaseFont.IDENTITY_H,
BaseFont.EMBEDDED);
new Font(bf, 12);
Once again, StackOverflowException
. While the consistency is nice, I'd prefer that the library would let me select a font.
I'm sure I've just got some configuration wrong somewhere; but it escapes me as to what it could be.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 nabble 上找到了这篇文章,建议在一个单独的线程,这样你就可以处理更大的堆栈。
FTA
在这里,RunSmartCopy 将完成您所描述的工作。
I found this article on nabble that suggests creating the font on a separate thread so you have a larger stack to deal with.
FTA
Here, RunSmartCopy would do the work you're describing.