[pdftex] Is hyperref link color stored in PDF file annotation data?

Doug McKenna doug at mathemaesthetics.com
Sun Jan 3 03:58:28 CET 2021


When I create a PDF using XeTeX (via TeXShop on MacOS), I use the hyperref package to create intra-document links.

I use the following to set the link color for them:

\hypersetup{
   linkcolor =[rgb]{0.4,0.1,0.4},    % Darkish purple
   colorlinks=true
   }

It all works as advertised.

I then open the built PDF file using a MacOS-based PDF viewer that I've built using Apple's PDFKit stuff (which allows me to query the PDF for various properties, among other things).  After much learning and hacking away (in Swift), all that seems to work.

I can get information about a link area on a PDF page (such as the rectangle containing the link-colored text), all of which is contained in what is called an annotation.  One of an annotation's properties is ... |color|.

But when I access this |color| property, it is always red, regardless of how linkcolor in the TeX file was originally set.  So the link color installed into the PDF (using pdfTeX primitives or \specials or whatever) would appear to be part of some other part of the annotation.

Questions:

How is hyperref's linkcolor stored in a PDF file?  Is it possible to determine from the PDF file itself what that color is in a structured, official way?  Is there some special key value being used?

Or is it a brute force thing where the PDF data can't distinguish from generalized colored text?


Doug McKenna
Mathemaesthetics, Inc.




More information about the pdftex mailing list.