Print to PDF doesn't support same-document anchor links (e.g. `<a href="#section-1.1">1.1</a>`)
Categories
(Core :: Printing: Output, defect)
Tracking
()
People
(Reporter: chansey97, Unassigned)
Details
Attachments
(2 files)
Steps to reproduce:
Print a webpage to PDF, but generated .pdf file doesn't support anchor link.
Reproduce steps:
- Open https://datatracker.ietf.org/doc/html/rfc1945 in Firefox.
Note that in this page I can jump to "1.1 Purpose" section via clicking the hyperlink "1.1" in "Table of Contents".
- File -> Print... -> Save to PDF -> Save.
Firefox then generates a file "RFC 1945 - Hypertext Transfer Protocol -- HTTP_1.0.pdf"
- Open that .pdf with a well-known PDF viewer (e.g. Adobe Acrobat) and click the the link "1.1".
Actual results:
Adobe Acrobat opens web browser to https://datatracker.ietf.org/doc/html/rfc1945#section-1.1
Obviously, this is not a expected behavior.
Expected results:
Adobe Acrobat jumps to "1.1 Purpose" section in the PDF.
Note that if the .pdf generated by Google Chrome, there is no problem.
Comment 1•2 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Printing: Output' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 2•2 years ago
|
||
Thanks for the bug report! I can reproduce. I think we only added support for links in print-to-PDF in the last year or two (I can't find the bug number, but I recall it being part of a cairo upgrade).
jfkthame, do you know if this use-case was supposed to be addressed by that? Or is this a known missing feature in our cairo-based PDF printing backend?
Comment 3•2 years ago
|
||
Comment 4•2 years ago
|
||
Comment 5•2 years ago
|
||
So in the Firefox print-to-pdf output, the 1.1
link is literally a link to https://datatracker.ietf.org/doc/html/rfc1945#section-1.1 as you can see if you open my first attachment and hover the 1.1
link. If you click it, you get redirected away from the PDF and to that^ site.
In the Chrome print-to-PDF output, the 1.1
link is a local in-doc link, which (as viewed with PDF.js) is pointed at https://bug1831751.bmoattachments.org/attachment.cgi?id=9332310#section-1.1 i.e. the anchor within the same document.
Updated•2 years ago
|
Comment 6•2 years ago
|
||
This is a known limitation. You can try enabling "internal" link destinations by setting print.save_as_pdf.internal_destinations.enabled
to true
in about:config
, but in some cases this results in an error generating the PDF; see bug 1725743. So until that issue is resolved, the feature is disabled by default.
There's been some recent work in this area in upstream cairo, so we should re-examine this and check whether pulling the latest fixes from there will allow us to re-enable internal links. That's bug 1729276, so this is basically a dupe of that issue.
Description
•