Itext 7 上的 ExceptionInInitializerError
我尝试使用 itext 7.2.1 制作 PDF,这是我的代码:
try{
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Kegiatan/" + eventName + ".pdf";
File file = new File(path);
file.mkdirs();
PdfWriter writer = new PdfWriter(file);
PdfDocument pdfDoc = new PdfDocument(writer);
Document document = new Document(pdfDoc, new PageSize(612, 936).rotate());
document.setMargins(0,0,0,0);
//Title
Paragraph paragraph = new Paragraph();
paragraph.add(new Text(eventName).setFontSize(14).setTextAlignment(TextAlignment.CENTER).setBold());
document.add(paragraph);
document.close();
}
catch (IOException e) {
e.printStackTrace();
}
我收到此错误消息,指向 document.close()
java.lang.ExceptionInInitializerError
我该如何解决此问题?
I tried to make PDF with itext 7.2.1, this is my code:
try{
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Kegiatan/" + eventName + ".pdf";
File file = new File(path);
file.mkdirs();
PdfWriter writer = new PdfWriter(file);
PdfDocument pdfDoc = new PdfDocument(writer);
Document document = new Document(pdfDoc, new PageSize(612, 936).rotate());
document.setMargins(0,0,0,0);
//Title
Paragraph paragraph = new Paragraph();
paragraph.add(new Text(eventName).setFontSize(14).setTextAlignment(TextAlignment.CENTER).setBold());
document.add(paragraph);
document.close();
}
catch (IOException e) {
e.printStackTrace();
}
I got this error message, pointing at document.close()
java.lang.ExceptionInInitializerError
How i can fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论