Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iTextSharp set default font-size

Tags:

c#

itext

I am using iTextSharp to create a new pdf-file. The pdf will contain one headline and one pdf-table. The file-size of the resultant pdf-file should be as small as possible, so I use the default font (Helvetica, 12pt). Is there a way to change the default-font-size from 12pt to 8pt.

I know that I can set the font for each pdf-table-cell.

But is it possible to set the default-font-size for the whole document/table, so that I don't need to set the font for each and every table-cell extra?

(I googled on this topic, but did not find an answer)

like image 549
Markus1980Wien Avatar asked Mar 09 '23 06:03

Markus1980Wien


1 Answers

Try this

BaseFont bf = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.NORMAL);


Paragraph p1 = new Paragraph(new Chunk("Sample text", font));
like image 176
Lara Avatar answered Mar 20 '23 20:03

Lara