# How to take out all links from a pdf, but keep their color?

I need to change my long physics book pdf file for printing. (The downloadable pdf with clickable links and embedded films will remain available and free.) The printer asked to take out all links from the pdf file. However, I would like to keep the original link colors. What is the best way to do it? Here are the details.

Most links are internal cross links, some links are defined with \url. The link colors are defined in hyperref. And I use the tex-dvi-dvips-pdf route. In addition, I need a solution with commands that can be loaded AFTER \usepackage{hyperref} has been called. At present I have two issues.

(1) If I use \let\url\nolinkurl, the corresponding links are gone, but so is their color. How can I keep the colors of the link texts? (Knowing that some links have special characters.)

(2) If I embed the whole text in \begin{NoHyper} ... \end{NoHyper} the internal crosslinks are gone, but the text that used to be a link is black. This happens in figure references, in the table of contents, in the subject index, etc. And I do not understand where to set the color now. And all the backrefs are also gone.

Any help would be very appreciated!

• When the printer asked you take out the links, it is likely that what they really meant is to take out the special colouring of the links. After all, the printer is concerned with the visual appearance of the printed page and not the interactive behaviour of the PDF as viewed onscreen in a PDF viewer. So keeping the appearance but removing the links is probably the opposite of what they want. Please check with them. Sep 8 '19 at 15:30
• No, the printer system gets confused by the (hyper-)links themselves, and wants a PDF/X file. After I took out the links, the printer system worked - I tested that already. Sep 8 '19 at 15:38
• Oh I see, the printer is an object, not a person… sorry been reading/watching too much old stuff lately and got confused. Sep 8 '19 at 15:46
• Off topic, Acrobat professional have option to switch-off all the links, do this helpful for you? Sep 9 '19 at 7:12

It seems that a solution to problem 1 is this one:

\def\url#1{\textcolor{mylinkcolor}{\nolinkurl{#1}}}


\let\url\nolinkurl


For problem 2, apart the solution given by Ulrike Fischer, there is also the option to transform a linked PDF into a PDF/X using Acrobat Professional, as mentioned by MadyYuvi in a comment.

In fact, there is one further way in Acrobat Pro: to use "Save as optimized pdf" and choose the settings so as to take all the links out.

Create a small wrapper mythesisprint.tex and input your pdf with pdfpages:

\documentclass{book}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages=-]{mythesis}
\end{document}


This will keep the colors but strip the annotations.

The ps2pdf route implements all interactive PDF features by means of the pdfmark PS operator. An efficient way to remove all interactivity without changing the visual appearance of the text might be neutralizing pdfmark and ?pdfmark:

\documentclass{article}

\special{!
userdict /?pdfmark systemdict /pop get put
userdict /pdfmark systemdict /cleartomark get put
}

\begin{document}

Go to page~\pageref{hello}.

\url{http://ctan.org}

\newpage

hello!\label{hello}

\end{document}

• The given suggestion works fine for \label and \ref but still the link comes for \url tag. Can you advise? please... Sep 14 '19 at 6:23
• @madyyuvi This link is autogenerated by the PDF viewer, in your case most likely Acrobat Reader, I guess. This happens with any text that looks like a URL, even without underlying PDF annotation. Sep 14 '19 at 7:36
• Thanks, I too thought the same, anyhow, much thanks for your confirmation.... Sep 14 '19 at 8:05