[英]How can I draw a rectangle into pdf file and fill it with text?
I've started to work on a simple Android project recently, where I have to collect some data from a database and put them into a pdf file. 我最近开始从事一个简单的Android项目,在该项目中,我必须从数据库中收集一些数据并将其放入pdf文件中。
I'd like to put these data into some rectangles, to get something like this: 我想将这些数据放到一些矩形中,以获得如下所示的内容:
I've read about rectangles on this post , and I think it's gonna work in Android too. 我已经在这篇文章中阅读了有关矩形的内容,并且我认为它也可以在Android中使用。 The only thing I can't get is how to fill my data into the rectangle.
我唯一无法获得的是如何将数据填充到矩形中。
Could you give me any suggestion, please? 请给我任何建议吗?
Thank you in advance... 先感谢您...
I have a similar code where i used table and set the value.It may provide you with some hint: 我在使用table并设置value的地方也有类似的代码,它可能为您提供一些提示:
private static Font blackFont = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD);
private void createSeg_Table(Document document)throws DocumentException,IOException{
PdfPTable table = new PdfPTable(1);
table.setWidthPercentage(100);
try{
PdfPCell c1 = new PdfPCell(new Paragraph("text you want to show",blackFont));
c1.setVerticalAlignment(Element.ALIGN_LEFT);
c1.setBorder(Rectangle.BOX);
table.addCell(c1);
document.add(table);
}
catch(Exception ex){
System.out.println(ex);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.