【问题标题】:Problems with formdata send via Adobe Reader to a php-script通过 Adob​​e Reader 发送到 php 脚本的 formdata 问题
【发布时间】:2010-02-03 12:38:40
【问题描述】:

我使用 Adob​​es LifeCycle 创建了一个 PDF,并添加了一些表单和一个按钮来将表单数据发送到 php 脚本。在服务器端,我抓取 postdata 并将它们存储到数据库中。到目前为止没有问题,但 Adob​​e Reader 现在会抱怨与 text/html 类型的内容有关的错误。

这是德语的错误信息:

Beim Senden ist ein Fehler aufgetreten。输入 des 类型 text/html kann nicht verarbeitet werden。

还有英文:

提交过程中发生错误。无法处理 text/html 类型的内容。

我是否必须在 php 脚本的输出中写入一些数据,以便阅读器知道一切正常?

【问题讨论】:

  • 你能为我们翻译那个错误信息吗?听起来你的假设是正确的。我敢打赌,读者正在寻找某种回应。
  • 所以,添加了英文错误信息

标签: php pdf adobe-reader


【解决方案1】:

另一种解决方案是使用 application/vnd.fdf 响应消息。 以下是 java 代码,但它具有示例 fdf 来发回消息 到 Acrobat Reader。

String userAgent = request.getHeader("user-agent");

if (userAgent.toUpperCase().startsWith("ACROFORMS")){
  response.setContentType "application/vnd.fdf");
  out.println("%FDF-1.2\n"+"1 0 obj<< /FDF << /Status (Form has been submitted!) >>      >>endobj\n"+
"trailer\n"+
"<< /Root 1 0 R >>%%\n");

}else
 ....

【讨论】:

  • 谢谢,mv288。这段代码 sn-p 对我非常有用。我在我的 PDF 表单测试页面中使用了它。
【解决方案2】:

我找到了解决方案,我必须将内容类型设置为 application/pdf 并读出一份感谢 pdf :)。现在 Adob​​e Reader 停止抱怨了,我有一种反馈给用户...

【讨论】:

    【解决方案3】:

    AspnetMvc 中的返回值

    String userAgent = Request.Headers["user-agent"];
    
                if (userAgent.ToUpper().StartsWith("ACROFORMS"))
                {
                    Response.ContentType = "application/vnd.fdf";
                    Response.Write("%FDF-1.2\n" + "1 0 obj<< /FDF << /Status (Form has been submitted!) >>      >>endobj\n" +
                   "trailer\n" +
                   "<< /Root 1 0 R >>%%\n");
                }
    

    【讨论】:

      猜你喜欢
      • 2015-04-18
      • 2011-04-09
      • 2018-02-06
      • 2018-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多