如何在java中使用itext在pdf中使用i18n
我使用印地语在pdf中显示表格的标题内容,但它在表格的标题部分显示空单元格
我创建了如下内容:
HttpServletResponse response = ServletActionContext.getResponse();
Document document = new Document();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
PdfWriter writer = PdfWriter.getInstance(document, buffer);
writer.setBoxSize("art", new Rectangle(36, 54, 559, 788));
document.open();
PdfPTable lineItemTable = new PdfPTable(cellval);
lineItemTable.setHeaderRows(1);
PdfPCell num1 = new PdfPCell(new Phrase("No",Bold_NORMAL));
num1.setHorizontalAlignment(Element.ALIGN_CENTER);
num1.setBackgroundColor(BaseColor.LIGHT_GRAY);
lineItemTable.addCell(num1);
PdfPCell lineval = new PdfPCell(new Phrase(""));
lineval = new PdfPCell(new Phrase(HindiItenName,Bold_NORMAL));
lineval.setHorizontalAlignment(Element.ALIGN_CENTER);
lineval.setBackgroundColor(BaseColor.LIGHT_GRAY);
lineItemTable.addCell(lineval);
document.add(lineItemTable);
document.close();
response.setContentType("application/pdf;charset=ISO-8859-1");
response.setHeader("Content-Disposition","attachment;filename=Invoice-"+invNumber+".pdf");
response.getOutputStream().write(buffer.toByteArray());
这是我的示例代码。你能帮帮我吗。提前谢谢
# 1 楼答案
召唤
关闭文档中某些结构的编写器循环。但我看到了许多没有做到这一点的例子。所以我不确定
内容类型是二进制的,不需要编码
错误提示:选择Unicode字体,标识为:
这里有一个嵌入式字体,因此在收件人方面不会有问题。 这是itextpdf.com的一本书的节选
要获得更好的浏览器体验,请执行以下操作: