【发布时间】:2012-05-20 16:40:31
【问题描述】:
我在 Web 应用程序中有以下用于 PDF 导出的代码,该应用程序创建了一个带有 2x2 表格单元格的 PDF。
public static void myexport2() throws IOException{
try {
com.itextpdf.text.Document document = new com.itextpdf.text.Document(PageSize.A4);
PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream("C://Users/gkarapatis/Desktop/testpdf.pdf"));
document.open();
document.addAuthor("Author of the Doc");
document.addCreator("Creator of the Doc");
document.addSubject("Subject of the Doc");
document.addCreationDate();
document.addTitle("This is the title");
HTMLWorker htmlWorker = new HTMLWorker(document);
String str="<table height=300, border=\"1\"><tr><td></td><td></td></tr><tr><td>1</td><td></td></tr></table>"
htmlWorker.parse(new StringReader(str));
document.close();
} catch(DocumentException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
当我将希腊字符添加到 HTML 单元格时,它不会出现在导出的 PDF 文件中。我应该怎么做才能将 Unicode 添加到我的导出中。 是 HTMLWorker 的问题吗?
当我尝试将图像添加到添加
的单元格时img src=\"file://C:/Webapp/dsp/public/images/dsp1.jpg\" width=\"80\" height=\"81\" alt=\"\" border=\"0\"
它给我抛出了一个异常。 我正在使用播放框架,它抛出的异常是“InvocationTargetException发生:null”
【问题讨论】:
-
这可能与您使用的字体有关吗?您是否尝试过指定具有希腊字符的字体?
-
我正在使用播放框架,它抛出的异常是 InvocationTargetException 发生:null
-
我试图指定一个 unicode 喜欢但可能不正确...有人可以帮忙吗?
标签: java playframework itext