Laurent,

Yes, it does indeed work with a flat submit, thank you very much for
the tip. The thing is, I was hoping that somehow I would be able to
get the PDF download starting, with optionally getting some data back
for a callback in case something fails and I do get JSON as a
response, which is impossible if I do a flat submit (am I wrong?). I
guess you can't have your cake and eat it too.

Brian,

Thank you for the Apache directive! Nice tip, although unfortunately I
am in an environment where I can't rely on Apache directives, since I
don't control that. Yes, I don't need AJAX to feed a file to the user,
but as I mentioned above, I would love to have it in case something
fails - in that case I can let the user know that something went
wrong. Perhaps there's a way to do that which I can't see?..

We are using FPDF (http://www.fpdf.org/), which is free and suits our
needs pretty well (generating two types of rather simple reports, as
well as an invoice). Anything better out there?

Best regards,
Max


On Oct 9, 5:34 pm, "Brian Williams" <[EMAIL PROTECTED]> wrote:
> 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 prototype-scriptaculous@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to