Font

fonttype
default
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 2.1.0.0

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 cjk_registry.properties 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 5:37 PM by cmwong, version 4

Comments

No comments yet.