根据当前填充颜色更改注释填充
Changing Annotation Fill based on current fill colour
我正在尝试根据当前填充或描边颜色更改注释的填充和描边颜色。
例如,注解填充的当前 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
}
}
如有任何帮助,我们将不胜感激。
您需要执行 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;
}
}
我正在尝试根据当前填充或描边颜色更改注释的填充和描边颜色。
例如,注解填充的当前 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
}
}
如有任何帮助,我们将不胜感激。
您需要执行 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;
}
}