6

This question might be seen is a follow up/complement to this question and answer. I'm actually taking the example from there:

\documentclass{article}
\usepackage{xcolor}
\usepackage{transparent}
\begin{document}
horse

ho\phantom{r}se

ho\textcolor{white}{r}se

ho\makebox[0pt]{{\transparent{0}r}}se
\end{document}

Four times the word horse. The first one is the regular word. The 2nd appears as ho se, because the r is invisible. The third also appears as ho se, but in contrast with the previous case, the word "horse" is contained in the document (appears as a search result, the copy/paste of the text, and the output of pdftotext). The last example appears as hose visually, but the text "horse" is contained in the pdf.

I need a the opposite case: I want the r to be visible but not contained in the text of the pdf. In other words, I want to be able to see the word horse on the pdf, but when searching the document (or mouse select + copy/paste, or pdftotext output), only the word "hose" appears.

Is this possible?

5
  • Related: tex.stackexchange.com/q/58851/87678 Jul 23, 2018 at 3:39
  • From my brief looking around, if you want to do this just for some words, the only option seems to be the pst-text package, which means you are stuck with latex→dvips→ps2pdf. If you want to do it for the whole document, you can use ghostscript to outline all fonts. Jul 23, 2018 at 4:07
  • Or if you only need the word horse, you could make the letter in inkscape and include it as a tikz picture. Jul 23, 2018 at 4:31
  • I don't know why, with MikTeX your example doesn't compile and says ! Undefined control sequence <argument> {\transparent{0}r}
    – AndréC
    Jul 24, 2018 at 5:37
  • Are you using pdflatex @AndréC? \transparent only works in PDF mode, not dvi
    – phollox
    Jul 24, 2018 at 10:48

1 Answer 1

5

Just use the accsupp (Accessibility Support) package.

\documentclass{article}
\usepackage{accsupp}
\begin{document}
\BeginAccSupp{ActualText=hose}%
horse%
\EndAccSupp{}%
\end{document}

enter image description here

$ pdftotext test.pdf -
hose

1
4
  • Thanks for the help @Henri-Menke. Quite a hack for the PDF. Never even crossed my mind searching for accessibility options, but it makes sense. Thanks again
    – phollox
    Jul 23, 2018 at 16:58
  • If you use another ripper (pdf2txt.py test.pdf) you can see the horse is still in your PDF.
    – abukaj
    Mar 21, 2023 at 16:53
  • @abukaj If you want to really obfuscate the PDF, so that no text can be recovered without OCR, you have to take further steps, see e.g. tex.stackexchange.com/questions/11307/… Mar 21, 2023 at 19:28
  • @HenriMenke I want the exact opposite (tex.stackexchange.com/questions/680303/…) - right now some characters in the PDF (--) are read by the reaper and misinterpreted. I want to force the reaper to see - where -- is displayed. But the link you provided may help, thanks!
    – abukaj
    Mar 21, 2023 at 19:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .