public File downloadNote(int noteId, String type, String leftPath)throws IOException, DocumentException {
Note note = noteDao.getNoteById(noteId);
String currentVersion = note.getHistory().get(note.getVersionPointer());
JsonObject obj = new JsonParser().parse(currentVersion).getAsJsonObject();
String content = obj.get("content").getAsString();
String htmlPath = leftPath + "htmlTemp.html";
File file = new File(htmlPath);
file.createNewFile();
FileWriter writer = new FileWriter(file);
writer.write("<body>" + content + "</body>");
writer.close();
if(type.equals("pdf")) {
String pdfPath = leftPath + "pdfTemp.pdf";
File pdfFile = new File(pdfPath);
exportUtil.htmlToPdf(htmlPath, pdfFile);
file.delete();
file = pdfFile;
}
//default html
return file;
}
DownloadServiceImpl.java 文件源码
java
阅读 45
收藏 0
点赞 0
评论 0
项目:TeamNote
作者:
评论列表
文章目录