我现在正在使用iTextSharp,我想使用自定义字体。
这是我到目前为止所拥有的:
PrivateFontCollection fonts;
FontFamily family = LoadFontFamily("TheFont.ttf", out fonts);
var reader = new PdfReader("KurtBonne_test.pdf");
var stamper = new PdfStamper(reader,
new FileStream("Kurt Bonne_test_withtext.pdf", FileMode.Create));
var over = stamper.GetOverContent(1);
over.BeginText();
var bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
//var bf = BaseFont.CreateFont("Test", BaseFont.CP1252, BaseFont.EMBEDDED, true,?,?)
over.SetFontAndSize(bf, 10);
over.SetTextMatrix(0, 140);
over.ShowText("page " + 0);
over.EndText();
stamper.Close();
现在,显然,BaseFont.CreateFont有一个带有此签名的重载方法:
BaseFont.CreateFont(string name, string encoding, bool cached, byte[] ttfAfm, byte[] pfb);
现在,我如何使用TheFont.ttf?不知怎的,我需要一个bytearray(ttfAfm)......