【发布时间】:2020-06-17 11:50:13
【问题描述】:
我在 PDF 编辑器中使用 Javascript。
我正在使用这个参考https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/js_api_reference.pdf
当在该字段上触发 mouseEnter 事件时,我正在尝试对该字段设置操作。 下面是我的代码。
var myDoc = app.newDoc(); // Create a blank doc
var Bbox = myDoc.getPageBox("Crop"); // Get crop box
var inch = 72;
// Add a text field at the top of the document
var f = myDoc.addField("Name.Last", "text", 0,[ inch, Bbox[1]-inch, 3*inch, Bbox[1]- inch - 14 ] );
f.setAction("MouseEnter", "f.textColor = color.yellow"); // Add an action
但是我得到以下错误:
======== Field : mouse enter ========
[ Line: 00000 { ReferenceError } ] : f is not defined
我以为我在这里使用这一行定义了字段 f:
var f = myDoc.addField("Name.Last", "text", 0,[ inch, Bbox[1]-inch, 3*inch, Bbox[1]- inch - 14 ] );
为什么错误提示我的字段未定义?
【问题讨论】:
-
你有Bbox的值吗?
-
是的 > [0, 792, 612, 0]
标签: javascript pdf acrobat acrobat-sdk