Closed Bug 2000439 Opened 8 months ago Closed 8 months ago

[macOS] gradient (e.g. linear-gradient) as background-image doesn't render, unless you add `print-color-adjust: exact` (but transparent areas still render as a solid color)

Categories

(Core :: Layout, defect)

Firefox 145
defect

Tracking

()

RESOLVED DUPLICATE of bug 1529152

People

(Reporter: w.richert, Unassigned)

Details

Attachments

(4 files, 1 obsolete file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:145.0) Gecko/20100101 Firefox/145.0

Steps to reproduce:

I have a web page created by Claude that uses

background-image: repeating-linear-gradient( transparent, transparent 27px, #d0d0d0 27px, #d0d0d0 28px );

for horizontal lines on the page.

Actual results:

When printing it, the whole page is black.

Expected results:

The web page should be white with just a few horizontal grey lines on it.

The Bugbug bot thinks this bug should belong to the 'Core::Layout' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Layout
Product: Firefox → Core

Can you share a loadable testcase that reproduces the issue for you? I suspect there might be more going on / more factors involved, beyond just that one line of CSS.

Also, does it reproduce in Print Preview and in "Save to PDF", or just with a physical printer?

I created a simple testcase using your background-image style, and so far am unable to reproduce. Here's what I used (which painted horizontal gray lines as-expected, in print-preview, printing to a real printer, and printing to our save-to-PDF virtual printer):

<!DOCTYPE html>
<style>
.lines {
  border: 5px solid black;
  height: 300px;
  width: 300px;
  background-image: repeating-linear-gradient( transparent, transparent 27px, #d0d0d0 27px, #d0d0d0 28px );
}
</style>
<div class="lines"></div>
Flags: needinfo?(w.richert)

Hi Daniel,

Thanks so much for looking into it! Here is an example HTML:

<!DOCTYPE html>
<html lang="de">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        @page {
            size: A4 landscape;
            margin: 0;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Georgia', serif;
            background: white;
            width: 297mm;
            height: 210mm;
            display: flex;
            margin: 0 auto;
        }

        .left-section {
            width: 50%;
            padding: 15mm;
            background: white;
            border-right: 2px solid #d0d0d0;
        }

        .right-section {
            width: 50%;
            padding: 15mm;
            background: #fafafa;
            position: relative;
        }

        .notes-header {
            font-size: 16pt;
            color: #7f8c8d;
            margin-bottom: 10mm;
            text-align: center;
            font-style: italic;
        }

        .notes-lines {
            width: 100%;
            height: calc(100% - 40px);
            background-image: repeating-linear-gradient(transparent,
                    transparent 27px,
                    #d0d0d0 27px,
                    #d0d0d0 28px);
        }

        @media print {
            body {
                -webkit-print-color-adjust: exact;
                print-color-adjust: exact;
            }
        }
    </style>
</head>

<body>
    <div class="left-section">
        <h1>test</h1>
        <div class="text-content">
            test
        </div>
    </div>

    <div class="right-section">
        <div class="notes-header">Notizen</div>
        <div class="notes-lines"></div>
    </div>
</body>

</html>
Flags: needinfo?(w.richert)

Thanks. That testcase prints just fine for me on Linux (to PDF and to my printer), but I can reproduce specifically on macOS, using save to PDF (and I assume it also reproduces when printing to a real printer from macOS, though I'm not bothering with that, to save ink).

Status: UNCONFIRMED → NEW
Ever confirmed: true
Attached file testcase 2 (obsolete) —
Attached file testcase 2

(whoops, reposting to fix a minor typo in testcase 2)

Attachment #9528860 - Attachment is obsolete: true

Two observations from printing testcase 2 to PDF (with "print backgrounds" checkbox checked, of course):
(1) by default, the gradient doesn't render at all (top box here)

(2) adding print-color-adjust: exact (bottom box here) makes it show up, but it doesn't work properly for colors that are interpolated with transparent - the original opaque color remains at full brightness. So the resulting PDF just has solid color-bars with no transparent regions.

Summary: Printing web page with certain background-image css results into black output → [macOS] gradient (e.g. linear-gradient) as background-image doesn't render, unless you add `print-color-adjust: exact` (but transparent areas still render as a solid color)

I'm using macOS Sequoia 15.7.2, for what it's worth.

Hmm, it looks like this is likely a duplicate of quite old bug 1529152. The reporter's testcase there also has a gradient that's attempting to draw lines, which renders as solid-black.

Status: NEW → RESOLVED
Closed: 8 months ago
Duplicate of bug: 1529152
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: