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
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;<br />
File output = new File("document.pdf");<br />
FileOutputStream fos = new FileOutputStream(output);<br />
PD4ML pd4ml = new PD4ML();<br />
pd4ml.setHtmlWidth(userSpaceWidth);<br />
pd4ml.render("http://www.w3.org/", fos);<br />
<br />
response.setContentType("application/pdf");<br />
response.setHeader("Content-Disposition", "attachment; filename=document.pdf");<br />
FileInputStream fileInputStream = new FileInputStream(output);<br />
int i;<br />
while ((i=fileInputStream.read())!=-1)<br />
{<br />
response.getOutputStream().write(i);<br />
}<br />
response.getOutputStream().flush();<br />
response.getOutputStream().close();<br />
fileInputStream.close();<br />
output.delete();