Document doc = new Document(new iTextSharp.text.Rectangle(564, 351));
PdfWriter writer= PdfWriter.GetInstance(doc, new FileStream(HttpContext.Current.Server.MapPath(“1.pdf”), FileMode.Create));
doc.Open();
PdfContentByte cb = writer.DirectContent;
cb.BeginText();
BaseFont bfont = BaseFont.CreateFont(@“c:\windows\fonts\SIMHEI.TTF”, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);//设定字体:黑体
cb.SetFontAndSize(bfont, 18);//设定字号
cb.SetCharacterSpacing(1);//设定字间距
cb.SetRGBColorFill(66, 00, 00);//设定文本颜色
cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, “在位置100,70处开始显示文本”, 100, 70,0);
cb.EndText();
doc.Close();
iTextSharp中绝对定位如何指定字体样式?
最新推荐文章于 2022-09-06 10:34:00 发布