尝试在java中使用iText 7。希望段落的一部分是大胆的。显然在早期版本中,这是通过格式化" chunks"分别然后将它们添加到段落中。显然" chunks"不存在于iText 7. iText 7的程序是什么?
答案 0 :(得分:12)
Text
中的 com.itextpdf.layout.element
是Chunk
的替代选择。
要使段落的一部分变为粗体,您需要为一段文本指定粗体字。
Paragraph p = new Paragraph();
p.add(new Text("this will be in bold").setFont(boldFont));
或者,您可以依靠iText模拟常规字体的粗体,但这不是首选方式。
p.add(new Text("bold will be simulated for regular font").setBold());
请查看Bruno Lowagie撰写的jumpstart tutorial。