[英]How to edit only the last modified annotation (Ink) using JavaScript with Acrobat XI?
I need to create several buttons in a PDF which when pressed will change the color of the Ink/Pencil tool in Acrobat. 我需要在PDF中创建几个按钮,按下这些按钮将更改Acrobat中“墨水/铅笔”工具的颜色。 I am not proficient in JavaScript and have been struggling to find adequate documentation for what I am trying to accomplish.
我不精通JavaScript,一直在努力寻找合适的文档来完成我要完成的工作。
I have found a way to do the reverse, I can make an annotation and have the button change the color of the Ink after it has been drawn. 我找到了一种相反的方法,我可以做一个注释,并让按钮在绘制墨水后更改墨水的颜色。 This satisfies my needs but I have not figured out how to only edit the LAST modified/created annotation.
这可以满足我的需求,但是我还没有弄清楚如何仅编辑LAST修改/创建的注释。 So far I have the following:
到目前为止,我有以下内容:
var buttonColor = this.getField("button").strokeColor;
this.syncAnnotScan();
var annots = this.getAnnots()
nSortBy: ANSB_ModDate
bReverse: true;
for (var i = 0; i < annots.length; i++) {
if (annots[i].type == "Ink") {
annots[i].strokeColor = buttonColor;
}
}
This results in the button changing ALL Ink annotations; 这将导致按钮更改所有墨水注释。 I am just not sure how to tell the script to only edit the LAST created/modified annotation (if possible), everything else is working as needed.
我只是不确定如何告诉脚本仅编辑LAST创建/修改的注释(如果可能的话),其他所有内容都根据需要工作。
You don't need to sort the annots to get to the last one created, it's always the last item in the array. 您无需对注释进行排序即可获得最后创建的注释,它始终是数组中的最后一项。 You don't need to pass any parameters to getAnnots().
您不需要将任何参数传递给getAnnots()。
var buttonColor = this.getField("button").strokeColor;
this.syncAnnotScan();
var annots = this.getAnnots();
if (annots[annots.length-1].type == "Ink") {
annots[annots.length-1].strokeColor = buttonColor;
}
You can see a PDF with this working at the URL below. 您可以在下面的URL上查看具有此功能的PDF。 https://files.acrobat.com/a/preview/69dd17f9-66f5-496b-a2d1-bfaab21ccdec
https://files.acrobat.com/a/preview/69dd17f9-66f5-496b-a2d1-bfaab21ccdec
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.