Search code examples
pdfacrobat

confirmation dialog (alert) after form submit


I was wondering if there is any way to notify a user in adobe reader that a pdf form has been submitted to the server? I am submitting a normal http/html form to a php script no big deal, straight forward, but there seems to be a big "black hole" in documentation, forums etc. as to what happens when the form is submitted.

Isn't there a way to trigger a javascript alert after I have submitted a form?? I dont't want to return another pdf that says "thank you", that is a bit tacky. I am very new to pdf forms so I am guessing there must be a way to return FDF to the original document that has some javascript in it that is executed eg alert('thank you for your feedback!')..

This should really be straight forward, I assumed Adobes much hyped PDF technology was much more developer freindly and accessible..

Any ideas?? (Oh and please don't ask why I am using pdf forms and not the web, this is coming from "The Top", so as a developer I just have to do it..)


Solution

  • The server script which you are posting to must reply with this content type in the HTTP header:

    'Content-Type: application/vnd.fdf'

    eg. If you are using PHP:

    header('Content-Type: application/vnd.fdf')
    

    followed by the relevant bastardized-pdf-javascript-mutant-half-bread that will trigger the alert() dialog.

    %FDF-1.2
    1 0 obj
    <<
    /FDF
        <<
        /JavaScript 
            << 
            /Doc 2 0 R
            /After (confirmSend();)
            >>
        >>
    >>
    endobj
    2 0 obj
    [ 
    (confirmSend) 3 0 R
    ]
    endobj
    3 0 obj
    <<
    >>
    stream
    function confirmSend()
    {
    app.alert({
        cTitle : 'title of the window',
        cMsg : 'message',
        nIcon : 3 
    });
    }
    endstream
    endobj
    trailer
    <<
    /Root 1 0 R
    >>
    %%EOF
    

    I hope you receive this message, as I wasted nearly 2 weeks of my life finding a solution...