Closed Bug 1831751 Opened 2 years ago Closed 2 years ago

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)

Firefox 111
defect

Tracking

()

RESOLVED DUPLICATE of bug 1729276

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:

  1. 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".

  1. File -> Print... -> Save to PDF -> Save.

Firefox then generates a file "RFC 1945 - Hypertext Transfer Protocol -- HTTP_1.0.pdf"

  1. 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.

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.

Component: Untriaged → Printing: Output
Product: Firefox → Core

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?

Flags: needinfo?(jfkthame)

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.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Print PDF doesn't support anchor link → Print to PDF doesn't support same-document anchor links (e.g. `<a href="#section-1.1">1.1</a>`)

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.

Status: NEW → RESOLVED
Closed: 2 years ago
Duplicate of bug: 1729276
Flags: needinfo?(jfkthame)
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: