How to get rid of the red box around hyperlink in PDF?
Asked Answered
I

5

11

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

Irresoluble answered 21/12, 2017 at 10:37 Comment(9)
In which programming language, using which PDF library, do you want to manipulate the PDF?Farnese
@Farnese It is a layman question. I admit it was not the ideal place to publish it. I have no intend of manipulating document with library, but if there are such solutions I would be happy to get them. Maybe there is some kind of CSS in PDF that can be tweaked?Irresoluble
As viewed in limited PDF viewers (like Chrome) the frame disappears, I would assume that the frame is built due to PDF annotation properties which the limited viewers ignore. Thus, the natural step would be to try and implement a tool that changes those properties.Farnese
This is viewer-specific. Most likely you're viewing the content using Adobe Reader. You can use something else, like Foxit, or SumatraPDF, or Google Chrome, ...Officious
@Officious Sumatra, Microsoft Nitro Reader and Foxit preserve red rectangles. Google Chrome viewer removes them but has no view capabilities as others.Irresoluble
@VladimirProtsenko: Are you interested running the output through some post-production to remove the boxes? It may also remove the hyperlinking, or do you want to keep that?Officious
@Officious I want to read text without annotations. It would be better to save links to have better navigation experience (chrome viewer satisfies this requirement).Irresoluble
@Farnese Thank you for the idea. I will dig into how the annotation layer can be disabled or removed from pdf in viewer or by the program.Irresoluble
@VladimirProtsenko: Here is another option.Officious
V
0

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.

Vasiliu answered 21/12, 2017 at 19:27 Comment(0)
L
18

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.

Leucopoiesis answered 21/12, 2017 at 10:44 Comment(3)
Where would one enter that in a PDF viewer?Linger
the document was created in latex using an older package version. The person who created the document needs to add the package specified above to the latex document. You cannot change the pdf. The creator of the pdf must change it.Leucopoiesis
@GaryMcHugh This is correct answer, but I am curious about other ways to go around this problem. As usr2564301 wrote I have no latex sources. I have one solution that I have added in update, but it is not possible to configure the chrome viewer to display two pages without slide mode.Irresoluble
K
4

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.

Khz answered 18/8, 2018 at 9:41 Comment(1)
This workaround worked for me, Thank you.Duodenary
W
3

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.

Worthwhile answered 23/2, 2020 at 1:22 Comment(0)
V
0

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.

Vasiliu answered 21/12, 2017 at 19:27 Comment(0)
C
-1

Check the packages used. If you find yourself using hyperref package, remove it from the \usepackage.

Consort answered 3/7, 2024 at 9:18 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.