Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change default font and fontsize in pdf using itextsharp

Tags:

itext

How do I set the default font and font size for a PDF document using iIextSharp so that it is used throughout the PDF.

like image 296
basnetujwal Avatar asked Sep 04 '25 16:09

basnetujwal


1 Answers

Met the same issue with Russian and Romanian alphabets(itextsharp 5.5.6.0, .net 3.5). I've just added:

string arialuniTff = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "ARIALUNI.TTF");
FontFactory.Register(arialuniTff);    
StyleSheet ST = new StyleSheet();
ST.LoadTagStyle(HtmlTags.BODY, HtmlTags.FACE, "Arial Unicode MS");
ST.LoadTagStyle(HtmlTags.BODY, HtmlTags.ENCODING, BaseFont.IDENTITY_H)

and

parser.SetStyleSheet(ST);

but before you start parsing your TextReader add:

parser.Parse(reader);

Otherwise it won't work.

like image 152
Radekk Avatar answered Sep 07 '25 18:09

Radekk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!