# How to convert text/listing into images

I would like to ask is there any way to covert some texts/listings to images so that they could not be copied?

I would appreciate any suggestions.

• just uploading the image of a typeset text into google docs or similar will give more or less complete text version, so the image will not greatly inconvenience anyone who wants to copy the text. – David Carlisle Jun 13 at 11:56
• Yes, I understand that it is possible to get the text from images. However, plagiarism is not my concern. I am supposed to convert certain texts into images for the first draft of the submission to the board... – Corey Jun 13 at 12:11
• tex4ht allows you to specify certain environments get converted to images (math or complicated tables usually) so I guess you could do that then re-include the images into the tex source. It depends how automated you ned it, you could always do as we do on this site just crop a screenshot of the pdf view – David Carlisle Jun 13 at 12:15
• @KJO another reason for doing this might be invisible text. I have had presentations given to me with the text covered up, and only a title on the slide (to tell students what questions will be given in a presentation). If you can copy paste the invisible text into a text editor, it destroys the point. – Thorbjørn E. K. Christensen Jun 13 at 12:41
• @KJO You can often find white letters on white backgrounds if you search through the pdf. I've often found seemingly invisible text by searching through presentations (to find the slides). to be honest I actually find that quite nice. If a presentation is mostly pictures, sometimes hidden text can take you to the figure you where looking for with a good search. – Thorbjørn E. K. Christensen Jun 13 at 12:59

You can use ImageMagick to convert the pdf to an image pdf. Running convert file1.pdf file2.pdf will create a pdf called file2.pdf which is about the same size as the input pdf but since its an image, the text cannot be selected. There is a notable decrease in quality though

To improve quality simply add a high density (eg 300):

convert -density 300 file1.pdf file2.pdf

an example:

\documentclass[htb]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{duckuments}
\usepackage{lipsum}
\begin{document}
\blindduck
\lipsum[1-20]
\end{document}


produces the markable text:

and can be converted to high quality pictures:

You can increase the density to above 300, if it was not enough

# Edit: unobtainable text

If your goal is not merely to turn the text into a picture, but make it unobtainable, you can make it the same color as the background:

\documentclass[htb]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{duckuments}
\usepackage{lipsum}
\begin{document}
\textcolor{white}{
\blindduck}
\lipsum[1-20]
\end{document}


Produces a pdf with markable text:

Converting it will make it both unmarkable and invisible, so you cannot obtain it from the pdf:

using the tool posted by @KJO on the above image I got the text:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, fells. Curabitur dictum

Leaving the duck completely out.

• @KJO yes, but OP wrote that plagiarism was not the concern, and as the text is to be submitted to a board, I think making it unreadable would be unwise. – Thorbjørn E. K. Christensen Jun 13 at 13:34
• Note that this solution converts the entire document. Converting or including per page is also possible with a similar method, but any smaller unit (a single paragraph, or a listing, as the OP mentioned) will be much harder to convert and re-include to the document. – Marijn Jun 13 at 13:52