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

Erik Stephens reportlab-users@reportlab.com
Thu Nov 11 17:05:44 EST 2004


On Nov 11, 2004, at 9:37 AM, Tim Johnson wrote:

> * Erik Stephens <erik@edgeos.com> [041111 00:16]:
>> On Nov 10, 2004, at 5:28 PM, Tim Johnson wrote:
>>
>>> I am using the following Function:
>>> ## code begins
>>> def pdf_header(file_name,size):
>>>    print (
>>>        'Content-type: application/pdf\n\n'
>>>        'Content-Length: %d\n'
>>>        'Content-Disposition: inline; filename="%s"'
>>>        ) % (size,file_name)
>>
>> Don't end the Content-type line with two newlines.  In HTTP, two
>> newlines signals the end of headers.  You should be seeing the other
>> header lines in the file you downloaded.
>
>   Sorry. Very confused here. If I remove one of those
>   newlines, I get a server error.
>   Message below:
>   malformed header from script. Bad header=%PDF-1.3: kbServePDF.py

Now put the double newlines after the last header, in this case, the 
Content-Disposition you're sending.  The two newlines will tell the 
browser that you're done sending headers.  That's why it started 
interpreting your PDF file as a header.

Best regards,
Erik




More information about the reportlab-users mailing list