<a class="savetopdf" href="#" onclick='
<%
try {
String w = result;// "<html><body> This is my Project </body></html>";
OutputStream file = new FileOutputStream(new File("E:\\newfile.pdf"));
Document document = new Document();
PdfWriter.getInstance(document, file);
document.open();
@SuppressWarnings("deprecation")
HTMLWorker htmlWorker = new HTMLWorker(document);
htmlWorker.parse(new StringReader(w));
document.close();
file.close();
} catch (Exception e) {
e.printStackTrace();
}
%>
>Save as PDF</a>
이것은 현재 PDF로 저장하기위한 코드입니다. 주어진 디렉토리에 저장하지만 한 번 클릭하고 싶습니다. pdf로 저장 한 다음 pdf 형식의 파일을 다운로드해야합니다.파일을 다운로드하는 방법 PDF 파일로 PDF 파일로 저장
것은이 SO 스레드 읽기 - http://stackoverflow.com/questions/1936615/jsp-download-application-octet-stream 및 기사를 http://balusc.blogspot.in/ ([파일을 봉사] 2007/07/fileservlet.html) – adatapost