Setting the Content-Disposition Header will work if you are opening the file in 
Adobe Reader first also (ie it will pre-fill the filename in the Save As box, 
but the end user can then change the name).  That's what I do.  

In C#:
String fileName = "whatever.pdf";
Response.AddHeader("Content-Disposition", string.Format("attachment; 
filename=\"{0}\"", fileName)); 

Erik Pfingsten


> -----Original Message-----
> From: Brian Lovett [mailto:[email protected]]
> Sent: Wednesday, May 26, 2010 10:20 AM
> To: [email protected]
> Subject: Re: [iText-questions] How to set the pdf's name dynamically
> 
> >From my experience, the "Content-Disposition" header works when you are
> saving directly to disk.  If you open it in a reader first, then it is up
> to that reader how it saves.  Based on the info presented, he is probably
> running in an Apache environment, so I am not sure how what I am about to
> suggest applies.  I run in a controlled Windows (IIS, IE, etc...)
> environment and we use Adobe Reader.  Reader uses the end of the URL as
> the default name of the file.  The way I resolved this was to set up a
> HTTP handler such that it intercepts anything with something like
> "http://server/printable/"; in the URL.  You could then set the URL to be
> "http://server/printable/filenameiwant.ashx";.  When you hit the save-as
> button in Reader, it would then auto-fill the file name with
> "filenameiwant".
> 
> So I would recommend Googling "Apache http handler". ;)  I hope this
> helps!
> 
> Thanks,
> 
> Brian
> 
> -----Original Message-----
> 
> Message: 9
> Date: Wed, 26 May 2010 08:49:21 +0200
> From: 1T3XT info <[email protected]>
> Subject: Re: [iText-questions] How to set the pdf's name dynamically
>       when using      servlet
> To: Post all your questions about iText here
>       <[email protected]>
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Zhu, Yunpu wrote:
> > I wanna decide pdf's name dynamically when I generate the pdf file using
> > a servlet and Jsp. The pdf is shown in browser. When I click save as,
> > the pop-up name is different during the different scenario.
> 
> That's not an iText question.
> The name of the file is defined in the HTTP header
> (Google for "Content-Disposition").
> --
> This answer is provided by 1T3XT BVBA
> http://www.1t3xt.com/ - http://www.1t3xt.info
> 
> --------------------------------------------------------------------------
> ----
> 
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> Buy the iText book: http://www.itextpdf.com/book/
> Check the site with examples before you ask questions:
> http://www.1t3xt.info/examples/
> You can also search the keywords list:
> http://1t3xt.info/tutorials/keywords/


This message, including any attachments, may contain information
which is confidential and privileged. Unless you are the addressee (or 
authorized to receive for the addressee), you may not read, use, copy 
or disclose to anyone the message, its attachments, or any information 
contained therein. If you have received the message in error, please 
advise the sender by reply e-mail and delete the message and any 
attachments.


------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to