PDF Generating Tool Support Forum

HOME   Login   Register    Search




  Subject: Open an explorer popup with save/open
   PostPosted: 12 Jul 2010, 17:26 
Hi (again :-p),

I search to open a dialog with save/open when I generate a PDF. How can I do it ?
I know that it seems to be possible to do it with tags but I can't to use them easily.

I tried to do it with setContentType(), setHeader()... but I didn't succeed...

Thanks for your help.


  Subject: Re: Open an explorer popup with save/open
   PostPosted: 13 Jul 2010, 13:02 
If you use PD4ML JSP taglib, just define inline="false" and fileName="file.pdf" attributes of <pd4ml:transform>

In servlet/PHP/etc scenarios, define

Content-disposition: attachment; filename=file.pdf

HTTP response header.


  Subject: Re: Open an explorer popup with save/open
   PostPosted: 13 Jul 2010, 15:34 
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 :

Code:
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();



[Reply]     [ 3 posts ] 

cron
Copyright ©2004-10 zefer|org. All rights reserved. Bookmark and Share