添加与编辑链接
让文档里的网址可点击,或者把指向外部的链接去掉。
这款工具完全在你的浏览器中运行。文件从不上传,你可以在浏览器的网络标签中亲自验证这一点。 亲自验证:打开浏览器的网络标签观察。你会看到一个查询你是否还有剩余任务的小请求,只包含工具名称和一段哈希,绝不会包含文件。
这款工具的作用
A URL printed in a PDF is usually not a link. It is text that looks like one, because whatever produced the document wrote the characters and never created the annotation that makes them clickable. This tool finds those and makes them real, lets you draw links by hand over anything else, and can strip existing links out. Links are annotations laid over a rectangle, so nothing about the page's appearance changes either way.
The common case is a document exported from a design tool or scanned from print where every web address is dead text. The other direction matters too: stripping outbound links from a document before it goes somewhere untrusted, or before it is published, so nobody follows a tracking address that was fine internally.
工作原理
- Drop the PDF onto this page.
- Leave automatic detection on for a first pass. Every URL and e-mail address found in the text is listed with the page it sits on.
- Draw a rectangle over anything else that should be clickable and give it a web address, or a page number to jump to inside the document.
- Turn on replacing existing links if the document already carries some and you would rather start clean.
- Press Save links and download the result.
Detection is harder than a regular expression over the page text, which is why most tools that offer it miss half the links. A PDF regularly splits one URL across several text runs, so a naive scan finds "https://exa" and "mple.com/report" and links neither. The runs on each line are joined before matching, which finds the whole address. Trailing punctuation is then trimmed - the full stop that ended the sentence rather than the one inside the domain - and a closing bracket is only dropped when it is unbalanced, because plenty of real addresses end in one and truncating those produces a link that leads nowhere. What is not linked is as deliberate as what is. A bare host with no dot in it is rejected, because in running prose "e.g" and "vs" match far more often than "http://localhost" appears, and a wrong link is worse than a missing one. An address beginning www. gets https:// in front of it, since a bare host is not a URI and readers show the annotation as broken. E-mail addresses become mailto: links, and an address inside a URL is not linked twice.
Links are written without a border and with the print flag set. The first is what stops readers drawing the black box round every link that made documents from the 1990s so recognisable; the second is what keeps the link alive when someone prints the document back to PDF. Internal jumps are written as explicit destinations that preserve the reader's current zoom and land at the top of the target page, rather than as named destinations, which break as soon as anyone splits or merges the file.
Running detection twice on the same document adds a second annotation over the same words unless you turn on replacing existing links first. Two stacked links behave unpredictably - readers pick whichever they find first - so turn that option on for a second pass, and leave it off when the document already carries hand-made links you want to keep.
Stripping outbound links is a separate pass and it ignores everything else on the page: every link with a web address is removed and the internal page-to-page jumps are kept, so a document keeps its own navigation and loses its ability to send a reader anywhere. Sanitise PDF is the wider version of this, removing JavaScript, launch actions and embedded files as well.
Detection needs the text of the document, which is read in your browser by PDF.js, and the annotations are written by pdf-lib in a Web Worker. No address in your document is looked up, resolved or checked against anything - which also means a link to a page that no longer exists is written exactly as printed.
这款工具做不到的事
- Detection can only find what is in the text layer. A scan has no text until it has been through OCR, and an address broken across two lines is read as two fragments, so neither is linked.
常见问题
- 为什么我 PDF 里的网址本来就点不了?
- 因为 PDF 里的链接是一个注释——附带动作的矩形——而不是文字的属性。Word 和大多数设计工具在你粘贴网址时会创建它,但导出路径会丢掉它,而扫描件从来就没有:它只有一张网址的图片。自动检测会读取文字、找到这些地址,并在其上写入缺失的注释。
- 我能从文档的一页链接到另一页吗?
- 能。画一个矩形,给它一个页码而不是网址。这个跳转会写成显式目标,保持读者当前的缩放级别,并落到目标页的顶部。若要整份目录,编辑书签通常是更好的工具——它给读者一个侧栏,而不是可点击的文字。
- 我怎么从 PDF 里移除链接?
- 有两种方式,效果不同。开启替换现有链接会在写入你所添加的内容前删除每个链接,所以什么都不加时就把它们全清了。移除对外链接则只取出指向网络的那些,保留页面之间的跳转——这正是文档要发到组织之外时你想要的。
- 我有些网址只被检测出一部分。怎么回事?
- 几乎总是换行造成的。检测器在匹配前会把一行内的文字块连接起来,所以在一行里分成几块的地址能被整个找到——但换到下一行的地址会作为两个片段到达,单独看都不像网址。请手动画出它们:每行放一个矩形,两个都填同一个地址。
- 这些链接会被检查或发到什么地方吗?
- 都不会。没有任何地址被解析、抓取或校验,文档也从不上传——文字提取和注释写入都在你的浏览器里进行。这也意味着印错的地址会变成同样印错的链接,所以保存前值得在列表里挑出那些明显有误的。