# Make portions of document images so that text within is not-searchable

I would like to create a macro that converts its paramater into an image with the goal that the text within this macro is not found using the search feature built into standard PDF viewers.

Thus, searching the resulting document for "text" should produce only two matches and not four. That is, any text in the highlighted box should ignored.

## Use-Case

I generate a large index of files and want to be able to search by the index entry only (and not the files names).

## MWE:

\documentclass{article}
\usepackage{tikz}

\tikzset{Node Style/.style={draw=red, thin, fill=yellow!50, anchor=base, inner sep=1pt,}}
\newcommand{\NonSearchableText}[2][]{%
\tikz[baseline] \node [Node Style, #1] at (0,0) {#2};%
}%

\begin{document}
\textbf{searchable text}
\indent\NonSearchableText{non-searchable-text}

\textbf{searchable text}
\indent\NonSearchableText{non-searchable-text}
\end{document}


## Desired Ouput

The desired output can be created by using the first file here to create the image non-searchable-text.png which is included by the second.

1. File name: non-searchable-text.tex

%%% https://tex.stackexchange.com/questions/34054/tex-to-image-over-command-line
\documentclass[convert={density=300,outext=.png}]{standalone}
\usepackage{tikz}

\tikzset{Node Style/.style={draw=red, thin, fill=yellow!50, anchor=base, inner sep=1pt,}}
\newcommand{\NonSearchableText}[2][]{%
\tikz[baseline] \node [Node Style, #1] at (0,0) {#2};%
}%

\begin{document}
\NonSearchableText{non-searchable-text}
\end{document}

2. Main File:

\documentclass{article}
\usepackage{graphicx}

%% https://tex.stackexchange.com/questions/98297/create-command-to-inline-an-image-in-a-question
\newcommand*{\Image}[1]{\includegraphics[valign=m]{#1}}%

\begin{document}
\textbf{searchable text}
\indent\Image{non-searchable-text.png}

\textbf{searchable text}
\indent\Image{non-searchable-text.png}
\end{document}

• The problem is that a PDF based image (like TikZ) probably includes the text as text In the (vector graphics) image. You would need to produce a rasterized image, which means using a graphics editor to convert. – John Kormylo Nov 5 '18 at 14:01
• You could precompute rasterized images of each letter. There might be something useful in tex.stackexchange.com/questions/29402/… – John Kormylo Nov 5 '18 at 14:10