I have been working like mad with PDFs built dynamically with PHP the last week.
One thing to be *absolutely* sure of is that you do not have ANY
output before the PDF download starts.
If you have Apache2 with mod_header loaded, there is a FilesMatch
directive to always force a download for a PDF
<FilesMatch "\.(?i:pdf)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
On a side note, you do not need AJAX for this feature to feed the user
a PDF file for download just set the form action to empty (same page)
and it should leave the page/browser right where it is with the form
still filled out, unless you are trying to feed a PDF to a div... you
aren't are you?
by the by which PDF library did you use to generate with?
On Thu, Oct 9, 2008 at 5:24 PM, lfortin <[EMAIL PROTECTED]> wrote:
>
> Hi Max,
>
>
> Using Form#request with a form performs an Ajax.Request, using the
> inputs of the form as serialized parameters.
> This might not bring you the behavior you expect to have.
>
> Maybe if you simply do a flat form submit, using $
> ('form_pdf').submit(); with all its inputs(hidden, text, ...) pre-
> filled:
>
>
> <form id="form_pdf" action="/any/url/">
> <input type="hidden" name="param1" value="anything">
> <input type="hidden" name="param2" value="anything">
> ...
> </form>
>
>
> hope it helps,
>
> -Laurent
>
>
> On Oct 9, 3:14 pm, spectrus <[EMAIL PROTECTED]> wrote:
>> Hello,
>>
>> I am trying to submit a form that calls PHP which generates a PDF file
>> and shoots it back to the user. When I do it using GET directly in the
>> browser address bar it works. However when I submit the form with
>> Prototype (either POST or GET) it doesn't:
>>
>> $('form_pdf').request({ parameters: params });
>>
>> I see the response headers in firebug set correctly as '
>> application/x-
>> download' (which are set in the back-end). Furthermore, the response
>> tab in the firebug console shows the actual contents of the PDF file
>> (flat-text gibberish).
>>
>> It must be something trivial, perhaps setting some parameter for the
>> request method. Does Prototype somehow override the headers when it
>> receives responses to its AJAX requests?
>>
>> If anyone has ever dealt with a similar issue, any pointers are
>> greatly appreciated.
>>
>> Regards,
>> Max
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---