Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
LaTeX macro to obfuscate text as an image (to prevent selecting, parsing, ...)
\makeatletter
\newcount\@imagecount
\newcommand\showasimage[1]{%
\global\advance\@imagecount 1
\edef\x{image-\the\@imagecount}%
\immediate\write18{echo '\unexpanded{\font\1=}\fontname\font' > \x.tex}%
\immediate\write18{echo '\unexpanded{\1#1\nopagenumbers\bye}' >> \x.tex}%
\immediate\write18{pdftex \x.tex}%
\immediate\write18{pdf2ps -dNoOutputFonts \x.pdf \x.ps}
\immediate\write18{ps2pdf \x.ps \x.pdf}
\immediate\write18{pdfcrop --hires \x.pdf \x.pdf}
\settodepth{\@tempdima}{#1}%
\raisebox{-\the\@tempdima}{\includegraphics{\x.pdf}}%
}
\AtEndDocument{%
\loop
\immediate\write18{rm image-\the\@imagecount.*}%
\advance\@imagecount-1
\ifnum\@imagecount>0\repeat
}
\makeatother
@maleadt

This comment has been minimized.

Copy link
Owner Author

maleadt commented Mar 27, 2015

Note that this requires passig --shell-escape to pdflatex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.