How to get color of annotations

Explorer ,
Apr 16, 2020 Apr 16, 2020

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?

TOPICS
Acrobat SDK and JavaScript

Views

44

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 17, 2020 Apr 17, 2020

Copy link to clipboard

Copied

LATEST

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines