Highlight Annotation Colors Are Not Read by FPDFPageObj_GetFillColor or FPDFPageObj_GetStrokeColor

10 views
Skip to first unread message

nadeeshan 2021

unread,
Oct 31, 2025, 1:30:51 PM (5 days ago) Oct 31
to pdfium

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:

  1. 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. 

  2. 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

23 0 obj
╰─ 60 0
<< /BBox [ 0 0 461.132 46.2507 ] /FormType 1 /Length 27 /Matrix [ 1 0 0 1 0 0 ] /Resources << /ExtGState << /R0 << /AIS false /CA 0.399994 /Type /ExtGState /ca 0.399994 >> /R1 << /AIS false /BM /Multiply /Type /ExtGState >> >> /ProcSet [ /PDF ] /XObject << /MWFOForm 24 0 R >> >> /Subtype /Form /Type /XObject >>
/R0 gs /R1 gs /MWFOForm Do

The annotation file  -  


highlights.pdf
Reply all
Reply to author
Forward
0 new messages