3

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..)

brndnmg
  • 257
  • 6
  • 21

4 Answers4

6

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...

brndnmg
  • 257
  • 6
  • 21
  • This seems to be a relevant ASP.NET solution: https://stackoverflow.com/a/25172000/478765 – ed22 Jun 12 '17 at 12:04
1

Thanks for this! I too have been searching for a solution to this for hours! It was extremely frustrating. It seems like overkill to install the FDF Toolkit just to get a simple confirmation dialog box after the PDF has been submitted.

I eventually came up with the following through trial and error (it seems there is absolutely no documentation about this on the net):

%FDF-1.2
%âãÏÓ
1 0 obj
<<
/FDF
    <<
    /Status(Thank you. Your details have been submitted and someone will get in touch with regarding your application.)
    >>
>>
endobj
trailer
<</Root 1 0 R>>
%%EOF

The above will present (or should present) a dialog box in Adobe Reader without showing the "Warning: JavaScript Window" warning.

Hope this ends up being useful to someone.

1

I wrangled with this for days, trying to figure out why when I sent the FDF using response.write, it just wouldn't display in Reader. I tried sending both hand-crafted FDF and installing the FDF toolkit to create the FDF response. I was able to create valid FDF, as I was able to open locally in Reader and have the pop-up display correctly but I couldn't get it to work for the life of me sending FDF from my ASP.NET page.

Then inspiration struck. In one of my attempts to send the FDF, I stored the FDF in a file and tried to use a streamreader to pump it into the response. After many unsuccessful attempts to use response.write, on a whim I tried response.redirect to the saved fdf file and it worked. I had previously added fdf as a registered MIME extension for my web site, with application/vnd.fdf as the MIME type. Now the user receives the pop-up after successful submission. The simple solution, in C#, looks like this:

Page.Response.Redirect("success.fdf");
Brent
  • 11
  • 1
0

I managed to happen upon the answer after 3 days of searching, adding a header for fdf file in the php script, adding '#FDF' to the end of the url in acrobat seems to have been the solution;

%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("The form has been successfully submitted\nThank you for your feedback!", 3); } endstream endobj trailer << /Root 1 0 R > %%EOF