简体   繁体   English

如何在Acrobat XI中使用JavaScript仅编辑最后修改的注释(墨水)?

[英]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.

相关问题 在Adobe Acrobat XI中使用JavaScript修改PDF字段值 - Using JavaScript in Adobe Acrobat XI to modify a PDF field value 如何使用Acrobat Javascript在Adobe Acrobat中创建真实的链接注释 - How can I create a real link annotation in Adobe Acrobat using Acrobat Javascript Adobe Acrobat Pro XI - 将Javascript添加到PDF - Adobe Acrobat Pro XI - Adding Javascript to a PDF 如何在Adobe Acrobat Pro中使用JavaScript将注释文本的一部分加粗 - How to make part of annotation text bold using javascript in Adobe Acrobat Pro 如何使用javascript仅为特定客户的最后插入行显示编辑按钮 - How to display Edit Button only for last insertion Row of specific customer using javascript 如何使用 Javascript 计算 Acrobat PDF 中的字段? - How to calculate fields in Acrobat PDF using Javascript? Acrobat PDF-使用Javascript,如何在打开文档时生成唯一编号(仅当字段为空时)? - Acrobat PDF - How to generate unique number when document opens - only if field is blank - using Javascript? 如何获取Javascript的上次修改日期 - How to get Javascript Last-Modified date 是否可以使用Adobe Acrobat XI和Gmail,Yahoo或客户端以外的其他smtp设置发送电子邮件? - Is it possible to send email using Adobe Acrobat XI using a different smtp settings other than for gmail, yahoo, or client? 如何循环用户输入的请求,直到用户在Acrobat XI中输入信息为止 - How do I loop a request for user input until the user enters information in Acrobat XI
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM