我正在尝试根据当前的填充或描边颜色更改注释的填充和描边颜色。
例如,Annotations填充的当前RGB是:
[" RGB",170 / 255,110 / 255,40 / 255]
我也需要使用此填充更改所有注释:
[" RGB",255 / 255,250 / 255,180 / 255]
我有以下情况,但我没有取得进展。
this.syncAnnotScan();
var annots = this.getAnnots();
for (var i = 0; i < annots.length; i++) {
if (annots[i].fillColor == ["RGB", 170/255, 110/255, 40/255]) { // What is the colour we are searching for?
annots[i].fillColor = ["RGB", 255/255, 250/255, 180/255]; // Fill Colour Change
annots[i].strokeColor = ["RGB", 255/255, 250/255, 180/255]; // Stroke Colour Change
}
}
对此的任何帮助都将非常感激。
答案 0 :(得分:2)
您需要执行color.equal(),根据文档说明:https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/js_api_reference.pdf(第430页)
this.syncAnnotScan();
var annots = this.getAnnots();
var annotsLength = annots.length;
var colourTarget = ["RGB", 0.9019622802734375, 0.0980377197265625, 0.2941131591796875];
var colourChangeTarget = ["RGB", 255/255, 250/255, 180/255];
for (var i = 0; i < annotsLength; i++)
{
if(color.equal(annots[i].fillColor, colourTarget))
{
annots[i].fillColor = colourChangeTarget;
annots[i].strokeColor = colourChangeTarget;
}
}