ItextSharp-如何给段落赋予颜色和粗体

问题描述 投票:1回答:2
Phrase p1Header = new Phrase("Hello World", FontFactory.GetFont("verdana", 15, Font.BOLD));

它只是让Hello World大胆。我也想给它上色。

c# itext
2个回答
0
投票

请尝试以下方法。

Phrase p1Header = new Phrase("Hello World",FontFactory.GetFont("Times New Roman", 10, Font.BOLD, new Color(255, 255, 255)));

0
投票

定义字体并添加到段落中

iTextSharp.text.Font myFont= FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 255));
Paragraph myParagraph = new Paragraph("MyField", myFont);
© www.soinside.com 2019 - 2024. All rights reserved.