使用JavaScript将当前日期放置到PDF表单的文本字段中 [英] Placing current date into a text field of a PDF form using JavaScript

查看:190
本文介绍了使用JavaScript将当前日期放置到PDF表单的文本字段中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢创建一个PDF,当打印出来时包含打印时的日期和时间。因为实际上改变PDF内容需要PDF编辑器,我认为使用PDF表单(即包含可填写表单的PDF),其中一个文本字段使用打印PDF时的当前日期和时间自动更新。 PDF的实际创建不是这个问题的目标(目标是使用 pdflatex ,这可以将JavaScript放入PDF中)。

我知道PDF可以包含JavaScript代码,但与网站相比有限制。是否可能(即受Adobe PDF JavaScript API支持)具有以下脚本:在打印PDF时触发


  1. li>
  2. 可以修改文本字段或用普通文本打印的其他内容

  3. 使用当前日期/时间更新此字段


解决方案

看完这篇文章后,我为我们的PDF产品写了一篇文章 - 创建仅打印PDF内容 - 表明这确实可行。我所做的是创建一个隐藏在屏幕上但在打印时可用的表单域。然后,我将JavaScript PDF操作添加到文档的before print事件中,以便将表单字段值设置为当前日期和时间。



免责声明:I为Gnostice工作。


I like to create a PDF which when printed out includes the date and time of when it was printed. Because actually changing the PDF content would require a PDF editor I thought using a PDF form (i.e. a PDF which contains a fillable form) where one text field is automatically updated with the current date and time when the PDF is printed. The actual creation of the PDF is not target of this question (the goal is to use pdflatex which can place JavaScript into PDFs).

I know that PDFs can include JavaScript code, but there are limitation compared to websites. Is it possible, i.e. supported by the Adobe PDF JavaScript API, to have a script which:

  1. is triggered when the PDF is printed
  2. can modify a text field or something else which is printed with the normal text
  3. update this field with the current date/time?

解决方案

After seeing this post, I wrote an article for our PDF product - Creating Print-Only PDF Content - to show that this is indeed possible. What I have done is create a form field that is hidden on the screen but available when printed. I then added a JavaScript PDF action to the "before print" event of the document so that the form field value was set to the current date and time.

DISCLAIMER: I work for Gnostice.

这篇关于使用JavaScript将当前日期放置到PDF表单的文本字段中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆