【发布时间】:2016-02-29 12:07:45
【问题描述】:
我正在使用 lowagie.text.pdf 库从我的 java 应用程序中创建一个 PDF 文档,但是我已经意识到其中包含双倍空格的字符串,即“双倍空格”没有被保留。这是一个 . PDF 限制还是我忽略了其他内容?
Font font = FontFactory.getFont(FontFactory.HELVETICA, 8);
float[] columnWidths = new float[columnCount];
PdfPCell headerCell = new PdfPCell(new Phrase(gridColumn.getCaption(), font));
PdfPTable table = new PdfPTable(columnWidths);
table.getDefaultCell().setBorderWidth(0.5f);
table.getDefaultCell().setBorderColor(Color.LIGHT_GRAY);
table.setHeaderRows(1);
for (PdfPCell headerCell : headerCells) {
table.addCell(headerCell);
}
String value = "DOUBLE SPACED";
table.addCell(new Phrase(value, font));
Document pdfDocument = new Document(PageSize.A4.rotate(), 0, 0, 0, 0);
ByteArrayOutputStream pdfStream = new ByteArrayOutputStream();
PdfWriter.getInstance(pdfDocument, pdfStream);
pdfDocument.addTitle(caption);
pdfDocument.open();
pdfDocument.add(table);
pdfDocument.close();'
谢谢。
【问题讨论】:
-
1.向我们展示您的代码。 2.我要说
com.lowagie(最高2.1.7)已经过时了,你应该使用com.itextpdf(5.0.0及更高-目前5.5.8,5.5.9将在3月发布)。跨度> -
请将您的代码添加到问题中。 cmets 中的格式混乱。
-
嗨,Amedee,我已经稍微重构了它!但我希望以上内容能让您对我要完成的工作有一个模糊的认识。
标签: java pdf pdf-generation