保存 PDF 表单信息

保存 PDF 表单信息

我正在使用 Hyperref 包构建表单。我希望能够保存填写在表单中的信息。

目前,我可以让它自动打开带有附加信息的电子邮件客户端:

\documentclass{article}
\RequirePackage{hyperref}
\begin{document}
\begin{Form}[action=mailto:[email protected],encoding=html, method=post]
\TextField[charsize={10pt},multiline=true,height={5mm},width={5cm},name={text_info},bordercolor={0.2 0.2 0.7},default={}]{}
\Submit{Submit}
\end{Form}
\end{document}

根据,我应该能够使用以下命令在本地保存表单:

\documentclass{article}
\RequirePackage{hyperref}
\begin{document}
\begin{Form}[action=my_form_response.doc,encoding=html, method=get]
\TextField[charsize={10pt},multiline=true,height={5mm},width={5cm},name={text_info},bordercolor={0.2 0.2 0.7},default={}]{}
\Submit{Submit}
\end{Form}
\end{document}

但是,当我单击提交按钮时,出现错误“打开 URL 以提交表单时出错”。

问题:我可以将表单数据保存在本地吗?怎样做?

答案1

action参数只能用于将填写好的表单发送到服务器(通过指定 CGI 脚本的 URL)或通过电子邮件发送(通过指定以 为前缀的电子邮件mailto:,如第一个示例所示)。要将数据保存到文件,您需要使用带有自定义 JavaScript 操作的按钮:

\documentclass{article}
\RequirePackage{hyperref}
\begin{document}
\begin{Form}
\TextField[charsize={10pt},multiline=true,height={5mm},width={5cm},name={text_info},bordercolor={0.2 0.2 0.7},default={}]{}
\PushButton[onclick={this.exportAsText()}]{Submit}
\end{Form}
\end{document}

这样,表单数据将转换为CSV 格式系统将提示用户将结果文件保存到磁盘。请注意,这需要付费版 Adob​​e Acrobat,免费的 Adob​​e Reader 未启用此功能(除非使用Adobe Experience Manager 表单)。

exportAsText通过将上述示例更改为以下之一,可以实现其他可能的输出格式:

  • exportAsFDF将数据保存在Adobe 表单数据格式,PDF 格式的简化版本。如果您想使用 Adob​​e 软件进一步处理数据,这将非常有用。
  • exportAsXFDF使用Adobe XML 表单数据格式,可以由 Adob​​e 软件以及所有 XML 解析器进一步处理。

相关内容