I have a pdf file obtained from the network and it has red boxes around links.

enter image description here

How can I get rid of them? How can I view the document without them?

P.S. Something that I found:

  • pdf is probably generated by latex,

  • non-commercial software is limited in modifying the document.

Update:

Facts disagree with the opinion that only author can change the way pdf looks. Below is an example of the same document in google chrome.

enter image description here

4

Best Answer


The document in your screenshot seems to have been created with LaTeX.

If you have the source code of the document, you can disable those red borders around links using

\usepackage[hidelinks]{hyperref}

Here's the documentation on the package hyperref.

Open it in Chrome browser. If there is no red rectangle anymore, then print it in the browser. Next change the option to "save as PDF". It works for me.

Having only recently ran into the same problem, I'm only now, belatedly, joining this discussion. Here's how I solved this problem under Linux.

(1) Uncompress the input PDF file infile.pdf by using the pdftk command

$ pdftk infile.pdf output outfile.pdf uncompress

(2) Open the uncompressed file for editing, say using vim

$ vim outfile.pdf

and search for the string Border [ to find out what is the color code used within the file for the link border. In vim you need to search with /Border \[. In my case, I found numerous lines such as this:

/Border [0 0 1]

indicating that the border is red.

(3) Using the border color code discovered in such a way (which in my case is red), run the global substitute command in vim to erase the border,

:%s/Border \[0 0 1\]/Border \[0 0 0\]/g

and save the changes. (You could use another code if you just want to change the border color, say \[0 1 0\] for green or \[1 0 0\] for blue.)

(4) Finally, compress the edited PDF file to produced the desired PDF version fixedfile.pdf without colored borders around the links:

$ pdftk outfile.pdf output fixedfile.pdf compress 

That was a fairly minimal file edit that removed the color border around the internal links while preserving them for use in navigation within the file.

Hope this will help anyone who might still be facing this problem.

There is no equivalent to CSS in PDFs. In general, you will have to visit every annotation on every page to find the link annotations and make them all invisible. There are two ways to make link annotation borders invisible, per my reading of the PDF Reference.

  1. remove the 'C' entry for every link annotation. Or make it an empty array.
  2. Add or modify the 'BS' dictionary entry to add a 'W' entry with a value of 0.

To actually implement this process, you would need a library that can open the PDF, modify its PDF Objects, and re-save it.