javascript 用javascript填写PDF表单

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15218666/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 23:54:37  来源:igfitidea点击:

Fill PDF form with javascript

javascriptjquerypdfadobe

提问by andrantis

This is what I have:

这就是我所拥有的:

  • User fills very long html form
  • User gets link to download different pdfs (this are fillable forms), links are generated using javascript
  • User clicks link, url is generated (with the data the user submitted before), data is processed in the form and fields are completed *this is done using javascript inside the form).
  • User get pdf back with fields completed.
  • 用户填写很长的 html 表单
  • 用户获得下载不同 pdf 的链接(这是可填写的表格),链接是使用 javascript 生成的
  • 用户点击链接,生成 url(使用用户之前提交的数据),在表单中处理数据并完成字段 *这是使用表单中的 javascript 完成的)。
  • 用户在填写完字段后返回 pdf。

The problem I'm running is that in some cases the data needed to send to the form is around 8000 characters, when IE only allows 2083 character in the url.

我遇到的问题是,在某些情况下,发送到表单所需的数据大约为 8000 个字符,而 IE 仅允许 2083 个字符在 url 中。

As requested by client, we need to do everything client side, that means no access to php, c#, java. Also I'm using Acrobat Pro X, to work with the pdfs.

根据客户端的要求,我们需要在客户端做所有事情,这意味着无法访问 php、c#、java。此外,我正在使用 Acrobat Pro X 来处理 pdf。

Is there a way to submit a post request, process that request in the pdf, fill the form and return the filled form to the user? Is there another way to go around the 2083 character limit of IE?

有没有办法提交发布请求,在 pdf 中处理该请求,填写表格并将填写的表格返回给用户?还有另一种方法可以绕过 IE 的 2083 个字符限制吗?

回答by Bruno Lowagie

Why do you need to send 8000 characters of data to the server if you want to fill out the form on the client side? Seems like all you need to do is to establish communication between the JavaScript in the HTML page and the JavaScript in the PDF. This is explained here: PDF hostContainer callback

如果要在客户端填写表单,为什么要向服务器发送8000个字符的数据?似乎您需要做的就是在 HTML 页面中的 JavaScript 和 PDF 中的 JavaScript 之间建立通信。这在这里解释:PDF hostContainer回调

PS: I'm the author of the book from which this excerpt was taken: http://www.javabeat.net/2011/04/javascript-communication-between-html-and-pdf-in-itext/

PS:我是摘录这本书的作者:http: //www.javabeat.net/2011/04/javascript-communication-between-html-and-pdf-in-itext/