Thanks! I was using
ns_return 200 appllication/pdf $data
which returns those headers, but the requested url is foo.html, so
even though the pdf viewer opens it (seeing the mime type
application/pdf), it barfs when it sees the .html file extension.
That's why I had to add the filename string to the Disposition header.
Even then the data was corrupt. Somewhere I think line endings are
getting added. Or a trailing newine or something.
- Ian
On 4/25/07, Tom Jackson <[EMAIL PROTECTED]> wrote:
You might try ns_write.
First use it to send the correct headers, then the data.
When I download a regular pdf with AOLserver I get these headers:
HTTP/1.0 200 OK
Last-Modified: Wed, 25 Apr 2007 16:04:14 GMT
MIME-Version: 1.0
Date: Wed, 25 Apr 2007 16:18:37 GMT
Server: AOLserver/4.5.0
Content-Type: application/pdf
Content-Length: 46411
Connection: close
(this is an empty line to signal end of headers)
(Then the raw pdf file with null chars)
tom jackson
On Wednesday 25 April 2007 08:36, Ian Harding wrote:
> Hello,
>
> I know this is an easy question, I am just not finding the answer right
> now.
>
> I create a pdf in memory. I know it's good, because I write it out to
> the filesystem to check it for debugging. The proc that creates it
> returns it to the caller then the caller sends it back to the client.
> Like this:
>
> set data [cart::print $cart_id $printer_id 0]
> if {[string length $data]} {
> ns_set put [ns_conn outputheaders] Content-Disposition:
> "attachment; filename=\"downloaded.pdf\""
> ns_return 200 "application/pdf" $data
> }
>
> The resulting pdf is corrupted.
>
> I assume something in the tcl procs handing the results back and forth
> is what's doing it. I don't want to write to the filesystem, or
> return directly from cart::print. Is there a way to do this? Should
> I park the data in an nsv or something?
>
> Thanks!!
>
> - Ian
>
>
> --
> AOLserver - http://www.aolserver.com/
>
> To Remove yourself from this list, simply send an email to
> <[EMAIL PROTECTED]> with the body of "SIGNOFF AOLSERVER" in the
> email message. You can leave the Subject: field of your email blank.
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]>
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject:
field of your email blank.
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]>
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject:
field of your email blank.