New issue
Advanced search Search tips

Issue 883026 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

-webkit-background-clip not applied when printing to pdf

Reported by a...@dytry.ch, Sep 11

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36

Example URL:
https://codepen.io/anon/pen/zJWRge

Steps to reproduce the problem:
HTML:
<style>
  #someText {
    font-size: 80px;
    font-weight: 700;
    background: linear-gradient(cyan, magenta);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
  }
</style>

<div id="someText">Some Text</div>

Open the above HTML file (or the linked codepen) in Chrome and try to print. The preview renders correctly, but if you export to PDF, the text background isn't clipped.

What is the expected behavior?
The PDF appears similarly to the browser preview, with the background gradient clipped to the text

What went wrong?
The text background isn't clipped. Instead of writing, only a gradient rectangle is rendered.

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? N/A 

Does this work in other browsers? No
 Firefox 62, Safari 11

Chrome version: 68.0.3440.106  Channel: stable
OS Version: OS X 10.13.6
Flash Version:
 
Screen Shot 2018-09-11 at 21.50.55.png
182 KB View Download
Cc: rtoy@chromium.org
Components: -Blink UI>Browser>PrintPreview
Labels: Needs-Feedback
Can't reproduce this with Chrome 69.  The rendered page shows the gradient with text, but the print preview is a blank page.  Saving as PDF produces a blank page (no text and no gradient).

But it seems wrong that the print preview doesn't look anything like the rendered page.

Setting component to UI>Browser>PrintPreview
One has to turn on "Background graphics" in Print Preview to see the text.

It works here with the "Save as PDF" destination in Print Preview on Linux. (See attached PDF output) I'll try a Mac and see what happens there.
883026.pdf
20.5 KB Download
Cc: halcanary@chromium.org
Components: Internals>Skia>PDF
Labels: -Needs-Feedback
Status: Untriaged (was: Unconfirmed)
OK, so this gets interested. The attached SkPDF generated 883026.pdf displays correctly in Adobe Acrobat, Chrome, libpoppler-based PDF viewers, and PDF.js. It displays incorrectly in Mac Preview.app and MS Edge.

Are some PDF viewers just buggy in this case? Dose the PDF contain something slightly ambiguous spec-wise?
Project Member

Comment 5 by bugdroid1@chromium.org, Sep 12

The following revision refers to this bug:
  https://pdfium.googlesource.com/pdfium/+/01c91e48b2838957adaf675bdde20d860217c7ff

commit 01c91e48b2838957adaf675bdde20d860217c7ff
Author: Lei Zhang <thestig@chromium.org>
Date: Wed Sep 12 21:44:12 2018

Roll testing/corpus/ e1005e0e7..6cd71979b (1 commit)

https://pdfium.googlesource.com/pdfium_tests/+log/e1005e0e7857..6cd71979b56e

$ git log e1005e0e7..6cd71979b --date=short --no-merges --format='%ad %ae %s'
2018-09-12 thestig Add more test PDFs to the corpus.

Created with:
  roll-dep testing/corpus

TBR=hnakashima@chromium.org
BUG= chromium:880920 ,chromium:883026

Change-Id: I9298f3da42b6682c1aab7f0d43cc3a1e2d935573
Reviewed-on: https://pdfium-review.googlesource.com/42354
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>

[modify] https://crrev.com/01c91e48b2838957adaf675bdde20d860217c7ff/DEPS

The PDF is interesting enough that I added it to the PDFium test corpus.

halcanary: I looked at the PDF and it seems well-formed. So I don't think we should do anything on our side. Instead, the bug reporter should file a bug with Preview.app. WDYT?
Project Member

Comment 7 by bugdroid1@chromium.org, Sep 12

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/cae0209f6aa85d1f229f47bec639d388639ae7b0

commit cae0209f6aa85d1f229f47bec639d388639ae7b0
Author: pdfium-chromium-autoroll <pdfium-chromium-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com>
Date: Wed Sep 12 23:22:44 2018

Roll src/third_party/pdfium 987416db2271..01c91e48b283 (2 commits)

https://pdfium.googlesource.com/pdfium.git/+log/987416db2271..01c91e48b283


git log 987416db2271..01c91e48b283 --date=short --no-merges --format='%ad %ae %s'
2018-09-12 thestig@chromium.org Roll testing/corpus/ e1005e0e7..6cd71979b (1 commit)
2018-09-12 rharrison@chromium.org Optimize CPDF_CMapParser


Created with:
  gclient setdep -r src/third_party/pdfium@01c91e48b283

The AutoRoll server is located here: https://autoroll.skia.org/r/pdfium-autoroll

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md

If the roll is causing failures, please contact the current sheriff, who should
be CC'd on the roll, and stop the roller if necessary.



BUG= chromium:880920 ,chromium:883026, chromium:881678 
TBR=dsinclair@chromium.org

Change-Id: I568df1014f4041ca53ea2aa93ef6837afd0b5329
Reviewed-on: https://chromium-review.googlesource.com/1222707
Reviewed-by: pdfium-chromium-autoroll <pdfium-chromium-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com>
Commit-Queue: pdfium-chromium-autoroll <pdfium-chromium-autoroll@skia-buildbots.google.com.iam.gserviceaccount.com>
Cr-Commit-Position: refs/heads/master@{#590855}
[modify] https://crrev.com/cae0209f6aa85d1f229f47bec639d388639ae7b0/DEPS

Owner: halcanary@chromium.org
halcanary: Per comment 3, can you decide whether we should do anything here, or mark this WontFix?
Here's what you are doing:

    sk_sp<SkShader> shader() {
        SkPoint points[2] = {{0, 0}, {0, 128}};
        SkColor colors[2] = {SK_ColorBLUE, SK_ColorGREEN};
        return SkGradientShader::MakeLinear(
                         points, colors, nullptr, 2,
                         SkShader::kClamp_TileMode, 0, nullptr);
    }
    void draw(SkCanvas* canvas) {
        canvas->saveLayer(nullptr, nullptr);
        SkPaint shaderPaint;
        shaderPaint.setShader(shader());
        canvas->drawRect({0, 0, 256, 128}, shaderPaint);
        SkPaint layerPaint;
        layerPaint.setBlendMode(SkBlendMode::kDstIn);
        canvas->saveLayer(nullptr, &layerPaint);
        p.setAntiAlias(true);
        p.setTextSize(80);
        canvas->drawString("TEST", 20, 90, p);
        canvas->restore();
    }

Maybe you could try this:

    void draw(SkCanvas* canvas) {
        SkPaint p;
        p.setAntiAlias(true);
        p.setTextSize(80);
        p.setShader(shader());
        canvas->drawString("TEST", 20, 90, p);
    }





crbug_883026.pdf
76.6 KB Download
crbug_883026_2.pdf
75.0 KB Download
Attached simpler test PDFs.
crbug_883026.pdf
5.0 KB Download
crbug_883026_2.pdf
3.3 KB Download
Status: Assigned (was: Untriaged)
This issue has an owner, a component and a priority, but is still listed as untriaged or unconfirmed. By definition, this bug is triaged. Changing status to "assigned". Please reach out to me if you disagree with how I've done this.

Comment 12 by halcanary@google.com, Yesterday (36 hours ago)

Attaching test case.
crbug-883026.html
331 bytes View Download

Comment 13 by halcanary@google.com, Yesterday (35 hours ago)

Attaching PDf from chrome-head-on-linux.
crbug-883026_73-0-3680-0.pdf
27.2 KB Download

Comment 14 by halcanary@google.com, Today (19 hours ago)

Screen Shot 2019-01-22 at 9.00.19 AM.png
551 KB View Download

Comment 15 by halcanary@chromium.org, Today (19 hours ago)

Attaching Adobe Reader screenshot
Screen Shot 2019-01-22 at 9.09.11 AM.png
619 KB View Download

Comment 16 by halcanary@google.com, Today (14 hours ago)

Owner: halcanary@google.com
I asked around about this error:
    https://groups.google.com/forum/#!topic/pdf-dev/QRc73S8G0sE

Comment 17 by halcanary@google.com, Today (14 hours ago)

Cc: -halcanary@chromium.org

Sign in to add a comment