views:

29

answers:

1

I'm using iTextSharp at the moment and I would like to use a custom font.

Here's what I have so far:

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();

Now, apparently, the BaseFont.CreateFont has an overloaded method with this signature:

BaseFont.CreateFont(string name, string encoding, bool cached, byte[] ttfAfm, byte[] pfb);

Now, how do I use TheFont.ttf? Somehow I need a bytearray (ttfAfm)...

+2  A: 

Why not do what is specified for "my expensive custom font" in this tutorial?

Tahbaza
Well, hadn't found that link yet. Thx, will surely find what I want there.
Lieven Cardoen