[reportlab-users] Serving a PDF file (naming problem)

Matej Pivoluska reportlab-users@reportlab.com
Fri Nov 12 08:09:42 EST 2004

Hello Tim,

D=F2a =A9t 11. November 2004 17:54 Tim Johnson nap=EDsal(a):
> > D?a ?t 11. November 2004 01:28 Tim Johnson nap=EDsal(a):
> > > I am using the following Function:
> > > ## code begins
> > > def pdf_header(file_name,size):
> > >     print (
> > >         'Content-type: application/pdf\n\n'

> ...
>   I eliminated the function and simply put in these two lines:
>   print 'Content-type: application/pdf\n'       ## first line
>   print 'Content-Disposition: attachment; filename=3D"my_ad.pdf"' ## seco=
> line
>   Absence the second line, IE dialogue presumes it to be
>   PDF (good). But inclusion of the second *still* does not cause
>   "my_ad.pdf" to be included.

I can't find anything good to put in your http headers to fix your problem,=
now. But I am pretty sure that I saw the solution 3-4 months ago.=20
I do not know, you can try insert filename parameter after media type name =
Content-type header:

print 'Content-type: application/pdf; filename=3D"myad.pdf"\n'

But I do not know if it will work for you.=20

Another solution that *works* is to use Apache rewrite engine.
See http://httpd.apache.org/docs/misc/rewriteguide.html

Ie insert this in .htaccess file in appropriate directory
RewriteEngine on
RewriteRule   ^/(.*)/my_ad.pdf$          /$1/my_ad.py

And then do the http request for my_ad.pdf directly.=20


>   thank you
>   tim

PS: Precisely, there exist a RFC 3778 [informational] about application/pdf=
media type. And some parameters (parameter follows after media type separat=
by semicolon) are interesting, ie

      Open to a specified named destination (which includes a view).

      Open the specified (physical) page.

More information about the reportlab-users mailing list