我想在PDF中插入一段包含粗體和非粗體區域的文本,但我不知道該怎麼做?合併兩個段落對象
我正在使用iText5(java)。
這是我的代碼:
public class CreatePdf{
private Font bigFont = FontFactory.getFont(FontFactory.HELVETICA, "Windows-1254", 12, Font.BOLD, new Color(0, 0, 0));
private Font smallFont = FontFactory.getFont(FontFactory.HELVETICA, "Windows-1254", 8, Font.NORMAL, new Color(0, 0, 0));
public void create(){
Paragraph parag1=new Paragraph("Number: ",bigFont);//This gonna be bold font
Paragraph parag2=new Paragraph("12", smallFont); //This gonna be normal font
//Create one paragraph from these two paragraphs. But How ?
}
}
我找到了解決方案:'段落梳=新的段落(); comb.add(new Chunk(parag1))com.add(new Chunk(parag2))'; – olyanren