iTextSharp设置默认字体大小 [英] iTextSharp set default font-size
问题描述
我正在使用iTextSharp创建一个新的pdf文件.pdf将包含一个标题和一个pdf表.生成的pdf文件的文件大小应尽可能小,因此我使用默认字体(Helvetica,12pt).有没有办法将默认字体大小从12pt更改为8pt.
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.
我知道我可以为每个pdf-table-cell设置字体.
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?
(我在这个主题上用Google搜索,但是没有找到答案)
(I googled on this topic, but did not find an answer)
推荐答案
尝试一下
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));
这篇关于iTextSharp设置默认字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!