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.
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
Thread smartCopyThread = new Thread(new ThreadStart(RunSmartCopy),
0x800000);
smartCopyThread.Start();
smartCopyThread.Join();
Here, RunSmartCopy would do the work you're describing.
精彩评论