Does flattening a PDF kill its hyperlinks?
You are about to flatten something. A filled-in form that has to go out as a record, or a report with comments on it that need pressing into the page. The document also has links in it — a contents page that jumps, a URL in the footer, forty citations that a reader is meant to click.
So you searched to check whether flattening takes the links with it, and page one is a wall of articles about how to remove hyperlinks from a PDF, which is the opposite of what you asked. Behind them are two Adobe forum threads from people asking your exact question, neither of them answered well.
Here is the honest version. With our Flatten PDF tool, no: links are deliberately left working, and the run tells you how many. But "flatten" names three different operations depending on who is doing it, and one of them does kill links — while leaving them looking exactly as they did. That is the part worth two minutes.
A link is two objects, and only one of them can be seen
This is the fact everything else follows from, and no page ranking for this query states it.
The blue underlined text is page content. When Word or InDesign or LaTeX writes out a link, it draws the words in a blue colour and strokes a line under them, in the same content stream as every other glyph on the page. Those instructions are ordinary drawing, indistinguishable from a blue heading.
The clickable part is an annotation. Separately, the producer adds an entry to the page's
annotation list: a /Link object holding a rectangle and an action. /A with a /URI for a web
address, /Dest for a jump to somewhere in this same document. It has no colour, no border width and
nothing to draw. It is a hit area, floating over the words, and a reader turns the pointer into a
hand when you are inside it.
Two consequences fall straight out of that split.
The first is why the "remove hyperlinks" articles have such unhappy comment sections. Delete the annotation and the blue underline stays exactly where it was, so the document still looks full of links and everybody assumes the tool failed.
The second is the answer to your question. Flattening means taking an object's appearance and writing it into the page so the object is no longer needed. A link has no appearance. There is nothing to write. Flattening a link cannot press anything into the page — it can only delete the annotation, which loses the click and keeps the look. That is the worst of both outcomes, and it is purely a loss.
Why ours leaves them alone, and what it says
Our flatten walks the annotations on each page and asks each one for its normal appearance stream. Form widgets and comments have one, so it is drawn into the page's content at the rectangle the object occupied and the object is deleted — the same mechanism a reader uses to display it, which is why the result holds up in software neither of you has heard of.
Anything with the Link subtype is put straight into the keep pile before that question is asked.
When you tick the comments option, the notes count them for you: "7 links were left working."
Flattening only the form fields — the default — cannot touch links either, because a link is not a form widget and the flattening runs over the form's own fields. You get no line about links in the notes in that case, because nothing looked at them. Silence there means untouched, not checked.
The three things called flattening, and which one costs you the links
The query has no universal answer because the word covers three unrelated jobs.
- Pressing annotations into the page, which is what we do and what most web tools mean. Whether
links survive is a decision the implementer makes. Acrobat's version — the Preflight fixup, and
the
doc.flattenPages()JavaScript behind it — clears the annotation list wholesale, links included. That is why the threads you found exist, and why the workaround posted in them is a script that records every link's rectangle and destination first and adds them back afterwards. - Re-rendering the document, which is what "just print it to PDF" means. The printing path speaks only in marks on paper and has no vocabulary for "this rectangle points at page 40", so every link goes, along with the bookmarks and the tags. The comparison is worth reading before you take that advice.
- Transparency flattening, which is a prepress operation on overlapping transparent objects. Different word, same spelling, nothing to do with annotations. We do not do it at all.
So if someone tells you flattening killed their links, they are almost certainly describing one or two, and they are right about their tool.
What does break a link, when flattening did not
Worth knowing, because people arrive here having blamed the wrong step.
- Deleting or reordering pages. An internal link points at a destination. Remove the page it aimed at and the click does nothing; move it and the click goes somewhere wrong. Nothing reports this, and it survives to the recipient.
- Editing the text under a link. The annotation stays at its old rectangle while the words reflow, so the hit area drifts off the phrase and sits over the middle of the next sentence.
- Anything that rasterises. A page turned into a picture of itself cannot carry annotations.
Counting the links you have, before and after
Our inspector reads page count, page sizes, encryption, tagging, the form field count and whether there is a real text layer, all in the browser — but it does not count links, which is worth saying plainly since this is the one page where you want that number.
Three ways to get it:
- Run Remove annotations from PDF on a throwaway copy with "links only" selected. The notes come back "Removed 34 links." Delete the copy; you now know what the flattened file has to still have.
qpdf --qdf --object-streams=disable in.pdf out.qdf, thengrep -c "/Link" out.qdf. QDF mode writes the objects out uncompressed and readable, so you can count the annotations and read the URLs they point at. qpdf is free and on every platform.- Open the flattened file in Firefox and hover. Its viewer builds real anchors, so the target appears in the status bar without you having to click through to forty websites.
Do the count before and after and the question stops being a matter of trust.
When you actually do want the links gone
Sometimes that is the job — a draft going outside with internal URLs in it, or a filing where live links are not wanted. Flattening is not the tool for that in either direction. Use Remove annotations from PDF with "links only": it strips the annotations and leaves the text, layout and pagination untouched, because nothing visible was ever involved. The blue underline will still be there afterwards, and that is not a failure — changing the look means editing the page itself in the PDF editor.
Nor does a password help. Password protect PDF encrypts the file and sets flags for printing, copying, editing and commenting. There is no flag for clicking, and a link in an encrypted document works exactly as it did.
The order to do this in
If the document is going out as a production or a filing, the sequence that keeps everything is: flatten first, then stamp with Bates numbering — which draws its references into the page content rather than adding annotations, so it neither disturbs the links nor adds any — then set a password if you need one, and sign last, because every one of those steps rewrites the file.
Done that way, the answers are permanent, every page has its reference, and the forty citations still go where the author put them.