-2
<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 形式のファイルをダウンロードする必要があります。

4

2 に答える 2