For specifying a file name you need to send the pdf as an ‘attachment’.

The following code chunk might help –

 

[code]

 

StringBuffer sbFilename = new StringBuffer();

sbFilename.append("PDFFILE");

sbFilename.append(".pdf");

StringBuffer sbContentDispValue = new StringBuffer();

sbContentDispValue.append("attachment");

sbContentDispValue.append("; filename=");

sbContentDispValue.append(sbFilename);

 

response.setHeader("Content-disposition", sbContentDispValue.toString());

 

Dayal

 

 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Pilby
Sent:
Tuesday, July 13, 2004 2:23 PM
To: iText
Subject: [iText-questions] RE: How to change PDF Title

 

Hi.

 

I have to following code in a SERVLET:

 

            Document document = new Document();
            
            response.setContentType("application/pdf");
            PdfWriter pdfw = PdfWriter.getInstance(document, response.getOutputStream());

 

            document.open();
            document.add(new Paragraph("Hello World"));
            document.close();
 

From the browser, I do get the expected PDF results. However, when I click File | Save (and somehow Save As is disabled) on the browser, the filename that comes up is a substring of the URL currently showing in the browser, and appended with ".pdf". How can I change this file name that keeps defaulting in the Save dialog text field?

 

For example, when I click the link to execute the above code in the servlet, my browser would display the PDF results. When I choose the File | Save option from the browser, the file name that appears is start_src=test.pdf, where start_src=test was from my URL (which was /start?src="">

 

Any help would be greatly appreciated.

 

Thanks.

 

David O.

 

Reply via email to