2
我現在使用的是iTextSharp,我想使用自定義字體。在C中獲取字體的字節數組#
這是我到目前爲止有:
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)...
btw,IText#殺了我,因爲PdfReader沒有實現IDisposable – abatishchev 2010-08-01 14:50:11