title: how to download file save as Pdf in Jsp
body: <pre><code>&lt;a class="savetopdf" href="#" onclick='
  
  &lt;%
      try {
          String w = result;// "&lt;html&gt;&lt;body&gt; This is my Project &lt;/body&gt;&lt;/html&gt;";
          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();
      }
  %&gt;
  &gt;Save as PDF&lt;/a&gt;
  </code></pre>
  
  <p>This is my code for save as Pdf currently it save to Given Directory But i want once i click on But save as PDf then It should download file which will pdf format. </p>