Hi
I am using Aspose.word to generate a PDF. Follwing code saves it to Server. How ever our requirement is that it saves to client location, either to their downloads or to their browser.
I searched in this forum and found two solitions.
1. By giving Content-Disposition on doc.save but looks like doc.save no longer supports it.
2. By giving response object, which I donot have in this helper class.
Appreciate any reference to this issue.
Thanks
public static void generateAsposePDFFromHtml(String html,String fileName) throws Exception {
ByteArrayInputStream input = new ByteArrayInputStream(html.getBytes("UTF-8"));
com.aspose.words.LoadOptions loadOptions = new com.aspose.words.HtmlLoadOptions();
loadOptions.setLoadFormat(com.aspose.words.LoadFormat.HTML);
loadOptions.setEncoding(Charset.forName("UTF-8"));
com.aspose.words.Document doc = new com.aspose.words.Document(input, loadOptions);
File localFile = new File("AsposePDF.pdf");
//saving it to callidus.appserver.log.dir
/*String inputFileName = defaultFileDownloadPath(fileName);
File localFile = new File(inputFileName);*/
BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(localFile));
try{
doc.save(outputStream, com.aspose.words.SaveFormat.PDF);
}catch(Exception ex){
logger.error("Exception in generating PDF using Aspose"+ex);
}finally{
outputStream.flush();
outputStream.close();
input.close();
}
}