3

MWE

\documentclass[a4paper,11pt]{article}

\begin{document}

NAME: \hfill SURNAME: \hfill \pdfliteral {q 1 Tr [.1 .4]0 d .1 w}SIGN\pdfliteral{q}\\

This text is not black.

\end{document}

And displaying

enter image description here

After the \pdfliteral, how is chancing normal text?

4

Package pdfrender

Package pdfrender provides a higher level interface for what you want to do. It uses the color stack of pdfTeX to provide rendering mode settings similar to colors. The solution via color stack also supports line and even page breaks.

\documentclass[a4paper,11pt]{article}
\usepackage{pdfrender}

\begin{document}

NAME: \hfill
SURNAME: \hfill
\textpdfrender{
  TextRenderingMode=Stroke, % 1 Tr
  LineWidth=.1, % .1 w
  LineDashPattern=[.1 .4]0, % [.1 .4]0 d
}{SIGN}

\bigskip
This text is back to normal (black).

\end{document}

Result

Low level via \pdfliteral

For one word, a color stack is not necessary, thus the following example shows, how it can be done using \pdfliteral. The important issue is, that saving the graphical state (operator q, command \pdfsave) must occur at the exact same place as restoring the graphical state (operator Q, command \pdfrestore). Otherwise the TeX coordinate system goes out of sync with the coordinate system of the PDF output page.

\documentclass[a4paper,11pt]{article}

\begin{document}

NAME: \hfill
SURNAME: \hfill
\mbox{%
  \pdfliteral direct{q 1 Tr .1 w[.1 .4]0 d}% without \pdfsave
  % \pdfsave
  % \pdfliteral direct{q 1 Tr .1 w[.1 .4]0 d}
  \rlap{SIGN}% position is *not* moved
  \pdfliteral direct{Q}% without \pdfrestore
  % \pdfrestore % same location as \pdfsave
  \hphantom{SIGN}% no we move
}

\bigskip
This text is back to normal (black).

\end{document}

Alternatively, the changed text rendering parameters can be reset manually, assuming the default values are in use.

\documentclass[a4paper,11pt]{article}

\begin{document}

NAME: \hfill
SURNAME: \hfill
\pdfliteral direct{1 Tr .1 w[.1 .4]0 d}%
SIGN%
\pdfliteral direct{0 Tr 1 w[]0 d}%

\bigskip
This text is back to normal (black).

\end{document}
  • Where can we find the documentation of \pdfliteral? How can we find out its argument spec? – Say OL Nov 24 '18 at 9:25
  • @SayOL PDF Reference – Heiko Oberdiek Nov 24 '18 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.