Copy link to clipboard
Copied
In the program for the selected fragment, I create an annotation,
I set the color of the annotation using the PDAnnotSetColor method.
The fragment is painted in the desired color. Next, I need to look at all the annotations created on the page and determine their color. I wrote this code:
int numAnnots = PDPageGetNumAnnots(pdPage);
for (int i = 0; i < numAnnots; i++) {
PDAnnot pdAnnot = PDPageGetAnnot(pdPage, i);
if (PDAnnotGetSubtype(pdAnnot) == ASAtomFromString("Highlight")) {
PDColorValue pdColorValue;
if (PDAnnotGetColor(pdAnnot, pdColorValue)) {
if (pdColorValue->space == PDDeviceRGB) {
ASFixed red = pdColorValue->value[0];
ASFixed green = pdColorValue->value[1];
ASFixed blue = pdColorValue->value[2];
double value1 = ASFixedToFloat(red);
double value2 = ASFixedToFloat(green);
double value3 = ASFixedToFloat(blue);
}
}
}
}
but an exception is thrown in the statement if (PDAnnotGetColor (pdAnnot, pdColorValue)). Where am I wrong?
Copy link to clipboard
Copied
Necessity is the mother of invention.
Since I could not get the color of the annotation, I went the other way. The color set of annotations for me is strictly fixed, so when creating an annotation using the PDAnnotSetDate method, I write down the color number (I renumber all the colors beforehand) as the month number on the date of creating the annotation. In the right place, using the PDAnnotGetDate method, I read the month number and thereby get the color number.