我想在一个PdfPCell中添加多个短语 . 我担心的是,我希望在一个单元格中以灰色字体显示“Created Date:”,而在黑色字体中显示“Date” .
那么,无论如何要做到这一点?请帮忙 .
代码就像,
PdfPCell cell = new PdfPCell(new Phrase("Created Date : ",grayFont));
现在,我希望在没有添加新Cell的情况下添加Date . 那可能吗?
创建一个单元格,并根据需要添加 Phrase :
Phrase
PdfPCell cell = new PdfPCell(); cell.addElement(new Phrase("Created Date : ", grayFont)); cell.addElement(new Phrase(theDate, blackFont));
您还可以考虑添加Chunk而不是 Phrase .
在Paragraph中使用不同的字体包装多个Phrase . 请注意:段落 will 原因 siblings (当然不是内容)包装,只要你不包装它们也是如此
使用
Phrase datePhrase = new Phrase(new Chunk("Created Date", FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD, BaseColor.GRAY))); datePhrase.add(new Phrase(new Chunk("Your Date", FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD, BaseColor.BLACK)))); PdfPCell cell = new PdfPCell(datePhrase);
3 回答
创建一个单元格,并根据需要添加
Phrase
:您还可以考虑添加Chunk而不是
Phrase
.在Paragraph中使用不同的字体包装多个Phrase . 请注意:段落 will 原因 siblings (当然不是内容)包装,只要你不包装它们也是如此
使用