HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › General questions / FAQ › Open an explorer popup with save/open › Re: Re: Open an explorer popup with save/open
July 13, 2010 at 13:34
#28104
Ok, thanks.
It was difficult but I succeed. It is a little bit sad and it need to be ameliorated but it works. A simple example :
int userSpaceWidth = 780;
File output = new File("document.pdf");
FileOutputStream fos = new FileOutputStream(output);
PD4ML pd4ml = new PD4ML();
pd4ml.setHtmlWidth(userSpaceWidth);
pd4ml.render("http://www.w3.org/", fos);
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment; filename=document.pdf");
FileInputStream fileInputStream = new FileInputStream(output);
int i;
while ((i=fileInputStream.read())!=-1)
{
response.getOutputStream().write(i);
}
response.getOutputStream().flush();
response.getOutputStream().close();
fileInputStream.close();
output.delete();
