Title: RE: Default filename for saving PDF from browser.

you can try this :


set        :  response.setContentType("application/pdf");
                response.setContentLength((int)tempFile.length());

and then you write the stream  :
        byte buffer[] = new byte[8192];
        int l = 0;
        os = response.getOutputStream();
        while ((l = is.read(buffer))> 0){
          os.write(buffer,0,l);
          os.flush();
        }
        os.close();

after that you set :
      response.setHeader("Content-Disposition", "attachment; filename test.pdf");

on WEB-XML under web-inf directory add this  :

        <servlet>
        <servlet-name>[SERVELT-NAME]</servlet-name>
        <servlet-class>[SERVLET-CLASS]</servlet-class>
        </servlet>
        <servlet-mapping>
          <url-pattern>/print/PDF/*.pdf</url-pattern>
          <servlet-name>[SERVELT-NAME]</servlet-name> 
        </servlet-mapping> 

on JSP file you can call this servlet using :
/print/PDF/test.pdf



-----Original Message-----
From: Sameer Pokarna [mailto:[EMAIL PROTECTED]]
Sent: 24 Juli 2003 8:33
To: [EMAIL PROTECTED]
Subject: RE: Default filename for saving PDF from browser.



Thanks for the response, Teator,

If I set the header as ("Content-Disposition", "attachment; filename.pdf"),
the PDF opens in PDF viewer separately, whereas if i replace the attachment
with inline, it opens up in PDF viewer in browser like a plugin.
In first case, SAVE option is disabled, in second case, save opens with link
name.

Is there a way of seeing PDF inline like a plugin, and save enabled, and
save default filename is filename.pdf ?

A combination is what I need.


Sameer Pokarna
Senior member - Technical staff
Phone: 91-20-5678900 x568

> -----Original Message-----
> From: Teator, Michael [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 24, 2003 5:57 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: Default filename for saving PDF from browser.
>
>
> You need to set a response header in the servlet for the filename
> to return
> to the browswer.
>
> -----Original Message-----
> From: Sameer Pokarna [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 24, 2003 6:56 AM
> To: [EMAIL PROTECTED]
> Subject: Default filename for saving PDF from browser.
>
>
>
> Hi,
>
> I am trying to create the PDF in a servlet and send it to the browser.
> The browser can see the PDF. When user tried to SAVE this PDF, the default
> name appears to be the whole link that was used to access the PDF.
>
> In 4.0, the default name is *.pdf, in 5.0, it is the whole GET
> request link.
>
> Is there any way in FOP to set the default filename?
>
> Any help would be appreciated,
> Thanks,
> Sameer Pokarna
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to