简体   繁体   English

在Adobe PDF中执行Javascript

[英]Javascript execution in Adobe PDF

I'm using iTextSharp in C# to read the pdf and fill values for text fields in it and based on one text field value, I'm trying to run javascript action to fill two other fields before saving the document. 我在C#中使用iTextSharp读取pdf并填充其中的文本字段值,并且基于一个文本字段值,我试图在保存文档之前运行javascript操作来填充其他两个字段。

I can see the script store in the pdf but it is not executing. 我可以在pdf中看到脚本存储,但未执行。 Is there a better way to run the scripts in iTextSharp or in adobe? 有没有更好的方法可以在iTextSharp或Adobe中运行脚本?

As far as I know, iText does not have an Acrobat JavaScript engine. 据我所知,iText没有Acrobat JavaScript引擎。

In order to run (Acrobat) JavaScript in your form, you will have to open it in Acrobat/Reader, and provide a trigger to execute the scripts. 为了在您的表单中运行(Acrobat)JavaScript,您将必须在Acrobat / Reader中打开它,并提供触发器来执行脚本。 Depending on which event the scripts are attached, you would either just have to run them (for example in the pageOpen event of the page on which the document opens), or using this.calculateNow() (again) in the pageOpen event of the page on which the document opens. 根据脚本附加的事件,您将只需要运行它们(例如,在打开文档的页面的pageOpen事件中),或者再次使用this.calculateNow() (在文档的pageOpen事件中)。打开文档的页面。 If you have a multi-page document, you may also add a mechanism which runs those scripts only once (how to do that has been explained many times in many places (here on stackoverflow, but also in the Adobe forums, the AcrobatUsers forums (rest in peace), PlanetPDF etc.). 如果您有多页文档,则还可以添加一种机制,该机制仅运行一次这些脚本(在许多地方对此方法的解释很多次(在stackoverflow以及Adobe论坛,AcrobatUsers论坛(安息),PlanetPDF等)。

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

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