1 year ago
#375992
aldi nugraha
ExceptionInInitializerError on Itext 7
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?
android-studio
itext7
0 Answers
Your Answer