udara22
asked on
PDF data post to Database
Hi guys,
My client want to send PDF form data to a database on click of a submit button. I created the Form in Acrobat X and set the submit button to HTML, and created a php file on my web server to grab the PDF POSTS. Everything works just fine on PC and MAC, I can received the data and it writes everything to the database perfectly.
The only issue is, on mac "Adobe Reader" if I click submit, it popup a message saying "An error occurred during the submit process. Cannot process content of type text/html" but the data actually goes in to my database fine.
Does anyone know whats the issue? This happends only on mac and only on reader, in Acrobat, it works just fine. :(
Thanks guys, this is pretty urgent, if someone can help asap I really appreciate it.
My client want to send PDF form data to a database on click of a submit button. I created the Form in Acrobat X and set the submit button to HTML, and created a php file on my web server to grab the PDF POSTS. Everything works just fine on PC and MAC, I can received the data and it writes everything to the database perfectly.
The only issue is, on mac "Adobe Reader" if I click submit, it popup a message saying "An error occurred during the submit process. Cannot process content of type text/html" but the data actually goes in to my database fine.
Does anyone know whats the issue? This happends only on mac and only on reader, in Acrobat, it works just fine. :(
Thanks guys, this is pretty urgent, if someone can help asap I really appreciate it.
ASKER
Thanks khkremer. Myadobe reader is 10. I tried putting a php header as content type : application/pdf. Then I got a different error. It goes like 'adobe cannot open ajdb37dje.tmp' not sure why that happends. How can i modify mime type?
You would use a header() command in PHP:
header('Content-type: application/pdf');
ASKER
Yep thats what I have.
Checkout the answers and my code here: https://www.experts-exchange.com/questions/27643383/How-to-send-PDF-data-to-SQL-database-on-clicking-a-submit-button.html
ASKER
@EddieShipman : Eddie, its one of 'my' questions too. Sorry, can you please tell me which answer you are referring to? Im actualling using FormTestSubmit.php from your solution as the base, it still gives the error.
@udara22, I didn't notice that. It was not obvious from your question above. I think it would have to do with the way the Mac Reader actually handles the submission via the javascript in the PDF form. Begin looking at that angle. It has nothing to do with your PHP.
ASKER
@EddieShipman : Eddy, I really think it's the FormTestSubmit.php file because If I add a header as header('Content-type: application/pdf') top the top of the php file , the pdf gives a different error. So I believe if I can some how find the right header, the issue will be fixed?
If I'm not mistaken, you are not sending a PDF but an FDF
ASKER
@Eddie, No. Im not sending a FDF. To pass the data 'TO' the pdf, im using FPDF , to pass the data 'FROM' the pdf im using POST to FormTestSubmit.php. And in FormTestSubmit.php I just have the post variables and sql query to write to database. No FDF in it, I removed it all together because its not necessary as FPDF does the job.
So now the issue occurs when the PDF send the data to the FormTestSubmit.php.
So now the issue occurs when the PDF send the data to the FormTestSubmit.php.
The problem is very likely in how the Mac Reader processes the response to a submit operation (just like you said in your previous comment). If the same operation works on Windows, the Mac Reader should behave the same way. I would try to downgrade my Reader version to the last Reader 9 release to see if that makes a difference. If it does, then you know that the problem is in Reader X, if it does not, the problem is specific to the Mac version of Reader. In both cases, I would file a bug report with Adobe at
https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
My contacts at Adobe tell me that they do read every bug report that comes in that way.
I checked your previous question, but could not find the code for your FormTestSubmit.php script. Would you mind posting it here, just to make sure we covered all the bases.
https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
My contacts at Adobe tell me that they do read every bug report that comes in that way.
I checked your previous question, but could not find the code for your FormTestSubmit.php script. Would you mind posting it here, just to make sure we covered all the bases.
ASKER
Hi khkremer. Actually in many cases when I try to contact adobe, their support is far below worse. They don't care about customers at all, just sell the products and after sales support and tech support ia nil. Once I was on the phonee for 1 hour and they didn't pick the phone. So that's why I don't even think about adobe customer support when i get an issue. They are just useless.
Anyway , maybe the issue is with the reader, I might try downgrading to see what happends, you got a point there. I'll also post the code when i go to the office tomorrow.
Anyway , maybe the issue is with the reader, I might try downgrading to see what happends, you got a point there. I'll also post the code when i go to the office tomorrow.
I can only tell you what I've heard from Adobe :) When you go to the Reader download page (http://get.adobe.com/reader/otherversions/) you can select from both Reader 9 and Reader X.
@udara22...
FormTestSubmit just returns an HTML page that shows the values posted. The problem seems to be that if you are opening the PDF in standalone reader, it doesn't know what to do with an HTML response. If you open the PDF in an embedded reader in a browser, it should work just fine.
FormTestSubmit just returns an HTML page that shows the values posted. The problem seems to be that if you are opening the PDF in standalone reader, it doesn't know what to do with an HTML response. If you open the PDF in an embedded reader in a browser, it should work just fine.
Good catch! That makes perfect sense.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@Eddie, The reason im not using embedded reader because Chrome has its own pdf engine and it doesnt allow people to fill forms in and the submit button doesnt work either. This happends on mac. And Mac Mozilla doesn't play good either. So I had to go with force download.
Thanks eddie for the link.Ok This is what Im doing now.
On the PDF submit button, I selected 'Send form - HTML' and linked it to www.web.com/formsubmit.php
On formsubmit.php I have this code
This includes
1. Header for fdf,
2. valuesSaved alert box for 'Values saved successfully'
3 the fdf data and writing it to a csv.
Now, when I click submit, at the top of the pdf reader, it says 'Some features have been disabled to avoid potential security risks. Only enable these features if you trust this document.' and I have to click 'Options' button and select 'trust'. When i click trust, it opens the pdf again, all my typed data is gone, and I have to type them again, and when I press submit again, it pops up the message. Is there a way to get the rid of the 'Trust' button and pass the valuesSaved() function?
@khkremer : I tried the pdf on Adobe Reader 9 (Mac), still the error pops us :S
Thanks eddie for the link.Ok This is what Im doing now.
On the PDF submit button, I selected 'Send form - HTML' and linked it to www.web.com/formsubmit.php
On formsubmit.php I have this code
<?php
header("Content-type: application/vnd.fdf");
?>
%FDF-1.2
1 0 obj
<<
/FDF
<<
/JavaScript << /After (valuesSaved();) >>
>>
>>
endobj
trailer
<<
/Root 1 0 R
>>
%%EOF
<?php
$filename = "data.csv";
$fp = fopen($filename, 'a');
$data = $_POST['1_1']. "\t" .$_POST['1_2']. "\t" .$_POST['1_3']. "\t" .$_POST['1_4']. "\t" .$_POST['1_5']. "\t" .$_POST['1_6']. "\t" .$_POST['1_7']. "\t" .$_POST['1_8']. "\t" .$_POST['1_9']. "\t" .$_POST['1_10']. "\t" .$_POST['1_11']. "\t" .$_POST['1_12']. "\t" .$_POST['1_13']. "\t" .$_POST['2']. "\t" .$_POST['3']. "\t" .$_POST['3_1']."\n";
fwrite($fp, $data);
fclose($fp);
?>
This includes
1. Header for fdf,
2. valuesSaved alert box for 'Values saved successfully'
3 the fdf data and writing it to a csv.
Now, when I click submit, at the top of the pdf reader, it says 'Some features have been disabled to avoid potential security risks. Only enable these features if you trust this document.' and I have to click 'Options' button and select 'trust'. When i click trust, it opens the pdf again, all my typed data is gone, and I have to type them again, and when I press submit again, it pops up the message. Is there a way to get the rid of the 'Trust' button and pass the valuesSaved() function?
@khkremer : I tried the pdf on Adobe Reader 9 (Mac), still the error pops us :S
ASKER
@khkremer : I use
pdftk pdf1.pdf output pdf2.pdf
to output the pdf using PDFToolKit. But this doesnt work when I password protect the PDF, could you please tell me how to pass the password through the command prompt. I want to allow print and allow editing input fields, but editing text or moving elements around?
ASKER
have to use
in the receiving php file
<?php
header("Content-type: application/vnd.fdf");
?>
in the receiving php file
Which version of Reader are you using on the Mac and on Windows?