简体   繁体   English

将PDF表单提交给PHP脚本仅在Adobe Reader XI中有效

[英]Submitted a PDF form to a PHP script only works in Adobe Reader XI

I have a PDF form that I want to submit to a remote php script. 我有一个PDF表单,我想提交给远程php脚本。 I thought I had it working but it seems only to be working when viewing the form in Adobe Reader XI. 我以为我可以使用它,但是似乎只能在Adobe Reader XI中查看该表单时使用。 The submit button just doesn't seem to do anything in Adobe Reader 10 or in the Previewer on Mac. 提交按钮似乎在Adobe Reader 10或Mac上的预览器中没有任何作用。 This is the javascript I have the button execute when it is clicked. 这是单击按钮时执行的Javascript。 It submits the entire PDF and also passes the email address and name for validation against a record in the database that the php script communicates with. 它提交整个PDF,还传递电子邮件地址和名称,以针对php脚本与之通信的数据库中的记录进行验证。

var email = getField("Your email").valueAsString;

var name = getField("Your name").valueAsString;  // get name field
name = name.replace(/(^[\s]+|[\s]+$)/g, '');        // trim spaces 
name = name.replace("'", "\\'");                    // change O'Neil to O\'Neil 
name = "'"+name+"'";

email = email.replace(/(^[\s]+|[\s]+$)/g, '');  

console.println("Your Plan is Being sent");

this.submitForm({
cURL: "http://example.com/thescript.php?name="+name+"&email="+email,
cSubmitAs: "PDF"});

Is there some syntax here that just isn't compatible with certain pdf readers? 这里是否有某些语法与某些pdf阅读器不兼容? Any advice would be greatly appreciated. 任何建议将不胜感激。

A few aspects: 一些方面:

• The script is OK so far, as it does work in Reader XI (and it also should work in Acrobat). •到目前为止,该脚本还可以,因为它可以在Reader XI中使用(并且也应在Acrobat中使用)。

• cSubmitAs: "PDF" requires that the filled form is saved. •cSubmitAs:“ PDF”要求保存填写的表格。 This is possible without limitations only in Reader XI; 没有限制,这仅在Reader XI中是可能的; in earlier versions, you would have to assign Extended Rights to the form, in order to make it saveable. 在早期版本中,必须将扩展权限分配给表单,以使其可保存。

• You might activate the Console in Reader X, in order to see whether there are indeed error messages. •您可以在Reader X中激活控制台,以查看是否确实存在错误消息。

• FORGET Preview.app!!! •忘记预览。 Preview.app does not support (Acrobat) JavaScript, and therefore, the script gets ignored. Preview.app不支持(Acrobat)JavaScript,因此脚本将被忽略。 But even worse, when saving a filled form, Preview.app messes up the document in a way that it is no longer usable. 但更糟糕的是,在保存填写的表单时,Preview.app会以无法使用的方式弄乱文档。 If there is a higher chance that your users use Preview.app, you have to protect the form by make it non-fillable by default, and use a document-level script to make it fillable. 如果您的用户更有可能使用Preview.app,则必须通过默认情况下使其不可填充来保护表单,并使用文档级脚本使其可填充。 In fact, that may be necessary if your form will also be used on iDevices etc. 实际上,如果您的表单也将在iDevices等上使用,则可能有必要。

Aside from the issues mentioned, it might be necessary encode special characters in cURL. 除了上述问题外,可能还需要在cURL中编码特殊字符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM