java 一个 PdfPCell 中的多个短语
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26159478/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Multiple Phrases in one PdfPCell
提问by Lalit Bhudiya
I want to add multiple Phrase in one PdfPCell. My concern is, I want to display like "Created Date :" in gray font and than "Date" in black font in one cell.
我想在一个 PdfPCell 中添加多个 Phrase。我担心的是,我想在一个单元格中以灰色字体显示“创建日期:”,而不是以黑色字体显示“日期”。
So, is there anyway to do this ? Please help.
那么,有没有办法做到这一点?请帮忙。
Code is like,
代码就像,
PdfPCell cell = new PdfPCell(new Phrase("Created Date : ",grayFont));
Now, I want to add Date after that without adding new Cell. Is that possible?
现在,我想在不添加新单元格的情况下添加日期。那可能吗?
回答by Alexis Pigeon
回答by specializt
回答by Yogesh Prajapati
Use
利用
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);