1

I would like to be able to use PDF files as pictograms in my document with the additional feature that the pictograms take the color of the text.

The PDF file I use is black.

So far, in order to use a PDF file as a pictogram, I use the command \includegraphics{} and then \scalerel*{} so that they have a good size.

When I change the color of the text, of course, the pictogram keeps the original color of the PDF. See for instance the picture at the end of the message.

Do you have an idea on how to do to be able to use PDF as pictograms in this way?

enter image description here

Colas
  • 6,772
  • 4
  • 46
  • 96
  • 2
    See https://tex.stackexchange.com/a/65083/2388 and https://tex.stackexchange.com/a/150219/2388. – Ulrike Fischer Mar 23 '20 at 09:23
  • If you can find a suitable icon in Font Awesome 5 then you can use the duotone options to color the icon (Pro version only), see for example https://tex.stackexchange.com/questions/528878. There is a chalkboard teacher icon, see the manual on page 8. – Marijn Mar 23 '20 at 10:47
  • Thanks @Marijn but I have many pictograms as this one. – Colas Mar 23 '20 at 13:33
  • @UlrikeFischer Do you if there is an automatic way to remove the color info of a PDF ? Anyway, thanks for your comment! – Colas Mar 23 '20 at 13:34

1 Answers1

4

Here's an option that could be relatively easily scripted for many PDFs.

I made a simple PDF black star in Inkscape (let's call it star.pdf).

I can uncompress it using pdftk:

pdftk star.pdf output star2.pdf uncompress

Then let's use sed to remove black fill and stroke setting commands (this assumes that your PDF only uses RGB black and they are in this format: 0 0 0 rg and 0 0 0 RG):

sed 's/0.0.0.[rR][gG]/        /g' < star2.pdf > star3.pdf

So star3.pdf now has its black colour commands removed.

Here's a sample test TeX file:

\documentclass{article}

\usepackage{xcolor}
\usepackage{graphicx}

\begin{document}

\includegraphics{star3.pdf}

\color{blue}

\includegraphics{star3.pdf}

\includegraphics{star.pdf}

\color{magenta}

\includegraphics{star3.pdf}

\end{document}

output

David Purton
  • 25,884