iTextSharp fonttype: Courier, Helvetica, Symbol, Times-Roman, ZapfDingbats

Your own font
You can register your own font.
pdfTpl.RegisterFont(@"C:\Windows\Fonts\verdana.ttf", "verdana", "");
pdfTpl.RegisterFont(@"c:\Windows\Fonts\arial.ttf", "Arial", "Identity-H");

//// using CJK
// need to load CJK b4 create PDFTemplateItextSharp
// itextsharp.dll 5.3.5 ok
// itextsharp.dll 5.1.3 not ok
iTextSharp.text.pdf.BaseFont.AddToResourceSearch("iTextAsian.dll"); // iTextAsian.dll

Moon.PDFTemplateItextSharp.PDFTemplateItextSharp pdfTpl =
new Moon.PDFTemplateItextSharp.PDFTemplateItextSharp(@"file\ar_statement.xml");

//// no need to give path for register CJK font
pdfTpl.RegisterFont("", "STSong-Light", "UniGB-UCS2-H"); //simplified chinese font
pdfTpl.RegisterFont("", "MHei-Medium", "UniCNS-UCS2-H"); // traditional chinese font

please check the file in the iTextAsian-src for the font name and encoding.

Then you can use the fontname that you register in the xml (fonttype).
<font fontsize="10" fonttype="STSong-Light">

Please refer to Project testPDFTemplateItextSharp for details.

Last edited Jul 21, 2013 at 6:37 PM by cmwong, version 4


No comments yet.