Do PDF Links Survive Translation? Build a Link Inventory
The link protocol is on the allowlist, which only indicates that this particular format check has passed; it does not imply that the target website is trustwort
Translating a PDF can change its links. Hyperlinks may point to the wrong place, and internal jumps may land on the wrong page after the file is split, merged, or run through OCR. This guide is for anyone who translates PDFs and needs those links to hold up.
You will learn how to build a link inventory: a script that sorts each link by type and flags the ones that need a person to check them. You will also see which decisions stay with people, and how to check the result before a translated document is delivered.
They do not guarantee results for every real file or product. Keep your original copies, and check any important file against the boundaries and acceptance criteria in this guide before you rely on it.
Do PDF links survive translation? The short answer
Links can survive translation if you inventory them before and after the process, classify each one, and have a person review the cases that code cannot judge.
| Your situation | What to do | Why |
|---|---|---|
| Your PDF has web (HTTP) links | Mark the protocol as permitted, then check the target website separately | Passing the protocol check does not mean the website is trustworthy |
| Your PDF has internal jump links | Record the zero-based target page, and remap it after splitting or merging | Page numbers shift when pages change, and zero-based indexing differs from what many readers expect |
| Your PDF has local action links | Flag the link for manual review | The code does not open or execute these links |
| Your PDF went through OCR or reformatting | Check link positions by hand | Link rectangles may no longer line up with the visible text |
| You are about to deliver a translated file | Run the classification on a representative PDF and review the audit report | The report should be stable and easy to interpret before it enters formal acceptance |
Before you start: the safety boundaries
Read these limits before you run anything:
- Passing these checks does not guarantee results for every real file or product.
- Keep original copies of every file you process.
- Check important files against the boundaries and acceptance criteria in this guide.
Build a self-contained synthetic example
The example builds its inputs in memory, so you can run it without a real document. Dependencies are listed in the import section.
import pymupdf
from urllib.parse import urlsplit
def classify(link):
if link.get("kind") == pymupdf.LINK_URI:
scheme = urlsplit(link.get("uri", "")).scheme.lower()
return "allowed_scheme_needs_review" if scheme in {"https", "http", "mailto"} else "blocked_scheme"
if link.get("kind") == pymupdf.LINK_GOTO:
return "internal_remap_needed"
return "manual_review"
with pymupdf.open() as source:
page = source.new_page()
page.insert_link({"kind": pymupdf.LINK_URI, "uri": "https://example.com/", "from": pymupdf.Rect(10, 10, 100, 30)})
raw = source.tobytes()
with pymupdf.open(stream=raw, filetype="pdf") as doc:
links = doc[0].get_links()
assert len(links) == 1
assert classify(links[0]) == "allowed_scheme_needs_review"
assert classify({"kind": pymupdf.LINK_URI, "uri": "javascript:alert(1)"}) == "blocked_scheme"
assert classify({"kind": pymupdf.LINK_GOTO, "page": 0}) == "internal_remap_needed"
assert classify({"kind": pymupdf.LINK_LAUNCH}) == "manual_review"
How the PyMuPDF link check works
The code follows the PyMuPDF API behaviour closely:
LINK_GOTOlinks use thepagekey, which is zero-indexed. They do not usetopageorfirstpagenum.get_text()with noclipargument returns the full page content.- The two assertions cover the normal path and a critical boundary condition. Both rely on real library behaviour, not hard-coded or circular expressions.
To see which fields each link dictionary contains, read the PyMuPDF Page.get_links() documentation.
Handle each link type
The table below lists the common link types, what to do with each, and what you should not assume.
| observation | What should be done | should not infer |
|---|---|---|
| HTTP link | only marks the protocol as permitted | target trustworthiness to be checked separately |
| internal jump | records the zero-based target page | after splitting and merging, remapped to |
| local action | marks manual review | does not open or execute |
Read the "should not infer" column carefully. An HTTP link that passes the protocol check still needs its target checked separately. An internal jump needs remapping after any split or merge.
Where code stops and people start
The code can perform mechanical classification, but it cannot replace business judgment. Its job is to sort links correctly, not to decide what should happen to them.
Keep these two ideas separate:
- Code demonstration: proves that the classification logic is correct.
- End-to-end effect: shows whether the translated document works for readers.
Someone who knows the document's business context must decide whether to keep a link or update its text. After OCR or reformatting, link rectangles can drift away from the visible text. A link can be safe and still be hard to use in that case, so a person needs to adjust it. To understand how link rectangles are positioned, see the PyMuPDF coordinate system explanation.
Use the checklist in document translation
Before you translate:
- Check that the page order, source locations, and text integrity are sound.
- Submit the same sample to the translation process.
After translation:
- Check that headings, body text, and figure captions correspond correctly.
- Do not rely only on whether the text reads smoothly.
Next steps
- Choose a representative PDF that contains mixed link types.
- Run the classification script in your local environment.
- Generate your first link audit report.
- Look at the share of entries marked "requiring manual review". Adjust your security policy constants or add to your whitelist based on that share.
- Add the report to your formal translation delivery acceptance process only after its content is stable and easy to interpret.
References
- PyMuPDF Page.get_links() Official Documentation
- PyMuPDF coordinate system explanation (understanding link rectangle positioning)
📊 At a glance
| Link type | Automated step | Who decides |
|---|---|---|
| HTTP link | Protocol is marked as permitted | Target website is checked separately |
| Internal jump | Zero-based target page is recorded | Page is remapped after splitting or merging |
| Local action | Flagged for manual review | A person reviews it; the code does not open or execute it |
🎯 Which approach fits you?
If you translate PDFs that contain web links
Run the protocol check, then check each target website separately. A passing protocol check does not confirm that a site is trustworthy.
If you split or merge PDFs during translation
Record zero-based target pages for internal jumps, and remap them after the file changes.
If your PDFs went through OCR or reformatting
Check link positions by hand, because the link rectangles may no longer match the visible text.
If you are preparing a translation for formal delivery
Run the classification on a representative PDF, review the audit report, and only add it to acceptance once the results are stable.
❓ FAQ
1. Does a passing protocol check mean a link is safe?
No. The protocol being on the allowlist only shows that this format check passed. The target website still needs to be checked separately.
2. Why do internal jump links need attention after splitting or merging?
Their target pages must be remapped, because page numbers change when a document is split or merged. The example records these targets using zero-based indexing.
3. Can the code decide whether a link should be kept?
No. The code performs mechanical classification, but whether to keep a link or update its text requires someone who understands the document's business context.
4. Can I rely on the examples for real files?
Not on their own. The examples use synthetic samples and do not guarantee results for every real file or product. Keep your originals and verify results against the acceptance criteria.
📝 Summary
Links can survive translation when you inventory them, classify each one, and have a person review what code cannot judge. Check your results against the checklist before you deliver a file.
OmniDoc translates PDF, Word, PowerPoint and Excel files: scanned pages are recognized first, table cells are translated one by one so tables keep their rows and columns, and a PDF comes back as both a bilingual and a translation-only file. Paid translation adds a glossary and context translation. Check the output against this checklist.
Try it now: upload a document and get it translated with the layout intact


