1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
String tempdir = System.getProperty("java.io.tmpdir");
String downPath = getServletContext().getRealPath("") + File.separator + UPLOAD_DIRECTORY;
// creates the directory if it does not exist
File downDir = new File(downPath);
if (!downDir.exists()) {
downDir.mkdir();
}
String filename = "lettre.pdf";
File temp = new File(downDir + File.separator + filename);
if (!temp.exists()) {
temp.createNewFile();
}
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(temp.getAbsolutePath()));
document.open();
addMetaData(document);
addTitlePage(document);
addContent(document);
document.close(); |
Partager