Join the Mozilla’s Test Days event from Dec 2–8 to test the new Firefox address bar on Firefox Beta 134 and get a chance to win Mozilla swag vouchers! 🎁

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

Howto include embedded links when printing to PDF?

  • 2 回覆
  • 3 有這個問題
  • 14 次檢視
  • 最近回覆由 mikemtnbikes

more options

I often print files out to share with students electronically and I want them to have access to the external links of a page. When trying to 'print' a file to PDF from the 'File->Print' context or 'Print Edit WE' addon, the URL links embedded in the original page are not retained. Is there a simple way to change this behavior.

I am running FF 56.0 on Ubuntu 16.04.

I often print files out to share with students electronically and I want them to have access to the external links of a page. When trying to 'print' a file to PDF from the 'File->Print' context or 'Print Edit WE' addon, the URL links embedded in the original page are not retained. Is there a simple way to change this behavior. I am running FF 56.0 on Ubuntu 16.04.

所有回覆 (2)

more options

Unfortunately, embedded links are not retained when printed. Firefox is sending the output in a format intended for a printer, not for an electronic document.

You may have noticed that some websites use a print style sheet to show all the links in parentheses after the link text in printouts. It often looks hideous. The trick is using a generated content style rule. As an example, you can open the Web Console on a page you want to print, execute a script, then use Print Preview to look at where the URLs are noted in parentheses.

To show the Web Console on the current tab, you can use either:

  • "3-bar" menu button > Developer > Web Console
  • (menu bar) Tools > Web Developer > Web Console
  • (Windows) Ctrl+Shift+k

An example script is as follows:

var s = document.createElement("style"); var t = '@media print{a:not([href^="javascript:"])::after { content: " (" attr(href) ")"; color: #000; }}'; s.appendChild(document.createTextNode(t)); document.body.appendChild(s);

This is a bit all or nothing, so it would be nicer to use a tool that adds just the URLs you care about...


Another possibility would be to use an add-on to generate the PDF. I don't recall whether I tested link preservation when I posted the following last month:

https://discourse.mozilla.org/t/so-many-pdf-converters/20193

more options

Darn. I was hoping for a simpler solution. Thanks for the information.