How can I convert a color name (such as used with the xcolor package) to a pdfliteral code, like q 1 0 0 rg (for red)?
Asked
Active
Viewed 664 times
11
raphink
- 31,894
1 Answers
14
\pdfcompresslevel=0 % to make everything visible in the pdf
\documentclass{article}
\usepackage{xcolor}
\def\usecolor#1{\csname\string\color@#1\endcsname\space}
\begin{document}
foo
\pdfliteral{\usecolor{red}}
bar
\end{document}
in pdf it is: 1 0 0 rg 1 0 0 RG
-
-
-
How to understand the arguments of
\pdfliteral? I use{241 240 240 rg}for green but it shows black – Ooker Dec 08 '17 at 16:25 -
colorpackage normally deal with this for LaTeX users, as this keeps code driver-independent. Also, with a sufficiently up-to-date pdfTeX or LuaTeX, why use\pdfliteralrather than\pdfcolorstack? – Joseph Wright Sep 19 '11 at 09:28\colorthere because I'm inserting PDF annotations from the Lua code. – raphink Sep 19 '11 at 09:30