有没有办法添加“替代文本” Adobe Acrobat 中 PDF 中的链接?
在 Adobe Acrobat Pro 中,向页面添加链接并不困难,但我想知道是否还有一种方法可以向链接添加“替代文本”(有时称为“标题文本”)。在 HTML 中,可以这样完成:
<a href="url" title="Text goes here">link</a>
然后,当鼠标悬停在链接上时,文本将显示为一个小工具提示。有 PDF 的等效项吗?如果是这样,你如何添加它?
In Adobe Acrobat Pro, it's not that difficult to add links to a page, but I'm wondering if there's also a way to add "alt text" (sometimes called "title text") to links as well. In HTML, this would be done as such:
<a href="url" title="Text goes here">link</a>
Then when the mouse is hovering over the link, the text appears as a little tooltip. Is there an equivalent for PDFs? And if so, how do you add it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
实际上 PDF 确实支持替代文本。它是逻辑结构记录的 PDF 参考 1.7 第 10.8.2 节“替代描述”的一部分
/Span << /Lang(en-us)/Alt(六点星)>> BDC (✡) Tj EMC
Actually PDF does support alternate text. It's part of Logical Structure documented PDF Reference 1.7 section 10.8.2 "Alternate Descriptions"
/Span << /Lang (en-us) /Alt (six-point star) >> BDC (✡) Tj EMC
在 PDF 语法中,链接注释支持内容条目作为备用描述:
引用“PDF 参考 - 第 6 版 - Adobe® 便携式文档格式 - 版本 1.7 - 2006 年 11 月” ”:
稍后:
这是当存在边框时,Sumatra PDF v3.1.2 可以很好地显示:
然而,其他 PDF 阅读器并未广泛支持此功能。
W3C 在其 WCAG 2.0 的 PDF 技术中推荐了另一种显示替代方案的方法用于辅助功能的链接上的文本:
In PDF syntax, Link annotations support a Contents entry to serve as an alternate description:
Quoting "PDF Reference - 6th edition - Adobe® Portable Document Format - Version 1.7 - November 2006" :
And later on:
This is displayed well with Sumatra PDF v3.1.2, when a border is present:
However this is not widely supported by other PDF readers.
The W3C, in its PDF Techniques for WCAG 2.0 recommend another ways to display alternative texts on links for accessibility purposes:
不可以,无法将替代文本添加到 PDF 中的链接。 PDF 参考中没有对此做出规定。
与此相关的是,PDF 中的链接和 HTML 文档中的链接的处理方式完全不同。 PDF 中的链接实际上是一种注释,位于页面顶部的指定坐标处,与文档中的文本或图像没有技术关系。 HTML 文档中的链接与它们超链接的元素有直接关系。
No, it's not possible to add alt text to a link in a PDF. There's no provision for this in the PDF reference.
On a related note, links in PDFs and links in HTML documents are handled quite differently. A link in a PDF is actually a type of annotation, which sits on top of the page at specified co-ordinates, and has no technical relationship to the text or image in the document. Where as links in HTML documents bare a direct relationpship to the elements which they hyperlink.
替代文本或替代文本与标题文本不同。标题文本是供人类消费的元数据。替代文本是媒体上的替代文本内容,以防媒体加载失败。
Alt text, or alternate text, is not the same as title text. Title text is meta data intended for human consumption. Alt text is alternate text content upon media in case the media fails to load.
还有一个技巧,使用不可见的表单按钮,该按钮不执行任何操作,但允许在鼠标悬停在其上方时添加一个小的弹出工具提示文本。
There is also a trick using an invisible form button that doesn't do anything but allows a small popup tooltip text to be added when the mouse hovers over it.
正式地,根据 ISO 32000-1 14.9.3 中定义的 PDF 1.7(请参阅 Adobe 网站免费下载相当于 PDF 1.7 的 ISO 标准的文档),将为注释提供替代文本 - 例如链接注释 - 通过将键“Contents”添加到其数据结构并提供替代文本作为该键的文本字符串值。
不幸的是,Acrobat 似乎没有提供用户界面来添加或编辑链接注释的“内容”文本字符串,即使它存在,也不会用于工具提示。相反,工具提示似乎始终是链接注释的目标,至少在它指向 URL 时是这样。
因此,在视觉层面上,人们可以通过在具有所需行为的链接注释区域顶部添加一些其他不可见元素来解决此问题。这不是一个很好的技巧,至少对我来说是这样。此外,它对 PDF 的可访问性没有帮助,因为它引入了另一个杂散对象......
Officially, per PDF 1.7 as defined in ISO 32000-1 14.9.3 (see Adobe website for a free download of a document that is equivaent to the ISO standard for PDF 1.7), one would provide alternate text for an annotation - like for example a Link annotation - by adding a key "Contents" to its data structure and provide the alt text as a text string value for that key.
Unfortunately Acrobat does not seem to provide a user interface to add or edit this "Contents" text string for Link annotations, and even if it is present it will not be used for the tool tip. Instead the tool tip always seems to be the target of the Link annotation, at least if it points to a URL.
So on a visual level one could hack around this by adding some other invisible elements on top of the area of the Link annotation that have the desired behavior. Not a very nice hack, at least for my taste. In addition it does not help with accessibility of the PDF, as it introduces yet another stray object...
面对同样的问题,我使用了JS lib“pdf-lib”(https:// /pdf-lib.js.org/docs/api/classes/pdfdocument) 编辑 pdf 文件的内容并添加注释上缺少的属性。
Facing the same problem I used the JS lib "pdf-lib" (https://pdf-lib.js.org/docs/api/classes/pdfdocument) to edit the content of the pdf file and add the missing attributes on annotations.