Hello all,
I am working with PDF files that contain highlight annotations, and I noticed an issue when trying to extract the annotation color using PDFium.
Specifically:
FPDFAnnot_GetColor does not return the color for these highlight annotations (The is expected as mentioned in the method). It returns false from the top of the method itself.
Attempting to use FPDFPageObj_GetFillColor or FPDFPageObj_GetStrokeColor also does not help. These functions only return the alpha value of the annotation, while the RGB values are returned as zero.
Upon inspecting the PDF file, I observed the following:
The annotation dictionary does include a /C property containing the RGB color values.
However, the appearance stream (/AP) does not contain the color information for these annotations.
Because of this, the color defined in the /C property is not read by any of the available PDFium APIs, neither FPDFAnnot_GetColor nor the page object color functions (FPDFPageObj_GetFillColor, FPDFPageObj_GetStrokeColor). I would appreciate it if anyone could point me to the recommended way to handle this situation. Thank you in advance!
Here are the annotation objects and the file.
Annotation Object
<< /AP << /N 23 0 R >> /C [ 1 0.384308 0 ] /CA 0.399994 /CreationDate D:20251012000047+05'30' /F 4 /M D:20251012000047+05'30' /NM 95ebcf19-0239-4983-ae52-424a30a70fc6 /P 22 0 R /Popup 61 0 R /QuadPoints [ 74.8 698.794 516.429 698.794 74.8 674.746 516.429 674.746 56.8 678.094 289.539 678.094 56.8 654.046 289.539 654.046 ] /Rect [ 56.0485 653.295 517.18 699.545 ] /Subj Highlight /Subtype /Highlight /T Folia Product /Ty
Appearance Stream
The annotation file -