New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 774970 link

Starred by 7 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows
Pri: 2
Type: Bug



Sign in to add a comment

Headless Print to PDF - entire image clipped when it overflows page

Reported by asonc...@gmail.com, Oct 16 2017

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

Steps to reproduce the problem:
1. Print HTML document from here: https://jsfiddle.net/ws5gn6vg/

Using the following headless options:

{
  landscape:           false,
  displayHeaderFooter: false,
  printBackground:     true,
  scale:               1,
  paperHeight:         6,
  paperWidth:          4,
  marginTop:           0,
  marginLeft:          0,
  marginRight:         0,
  marginBottom:        0,
  pageRanges:          ''
}

What is the expected behavior?
Images which overflow the page size should be partially clipped - their parent container has "overflow: hidden;" rule defined.

What went wrong?
Some images are entirely clipped. This seems to happen if the absolute position is set using 'top' causing overflow, but appears to work correctly using 'bottom' with a negative value (see HTML document for styles).

Did this work before? N/A 

Chrome version: 61.0.3163.100  Channel: stable
OS Version: Ubuntu 16.04 LTS x64
Flash Version: 

Size units (px vs in) do not seem to make a difference.
 
pdf-clip.png
7.0 KB View Download
pdf-no-clip.png
8.3 KB View Download
pdf-no-margins.pdf
4.0 KB Download
pdf-margins.pdf
4.1 KB Download

Comment 1 by asonc...@gmail.com, Oct 16 2017

Attached HTML document in case jsfiddle link is removed.

tpl4.html
3.1 KB View Download

Comment 2 by asonc...@gmail.com, Oct 16 2017

May be related to https://bugs.chromium.org/p/chromium/issues/detail?id=772685, but the issue occurs with any element, not just SVGs.

Comment 3 by asonc...@gmail.com, Oct 16 2017

JSFiddle link is wrong, please use HTML document attached above.

Comment 4 by asonc...@gmail.com, Oct 16 2017

Correct fiddle: https://jsfiddle.net/agywqwdv/
Labels: Needs-Triage-M61 Needs-Bisect
Cc: vamshi.k...@techmahindra.com
Labels: -Needs-Bisect M-64 Triaged-ET OS-Windows
Status: Untriaged (was: Unconfirmed)
Able to reproduce this issue on reported chrome version stable 61.0.3163.100 and on the latest canary 64.0.3241.0 using Ubuntu 14.04 and Windows 10 with steps mentioned in Comment#0.
Note: In Mac 10.12.6 issue is not seen.  

This issue is seen from M50[50.0.2634.0]. Hence treating it as non-regression and marking as untriaged.

Comment 7 by asonc...@gmail.com, Oct 17 2017

Note that the fiddle URL in the original post is incorrect. Please use https://jsfiddle.net/agywqwdv/ or the uploaded HTML file.

Comment 8 by caseq@chromium.org, Oct 17 2017

Cc: caseq@chromium.org eseckler@chromium.org
Components: -Platform>DevTools Internals>Headless
Owner: jzfeng@chromium.org
Status: Assigned (was: Untriaged)

Comment 9 Deleted

Comment 10 by asonc...@gmail.com, Oct 29 2017

I added a simplified test case showing images being clipped entirely when they overflow pages.

The second page overflows by 0.1in, and the image disappears (see clipped-image.pdf).

If 'overflow: hidden;' rule is removed from the page, then a third page is created and the image is pushed onto it (see extra-page.pdf).
image-clip.html
661 bytes View Download
clipped-image.pdf
4.4 KB Download
extra-page.pdf
4.8 KB Download

Comment 11 by asonc...@gmail.com, Oct 29 2017

Previous test case was printed using the following parameters:

{
  landscape:           true,
  displayHeaderFooter: false,
  printBackground:     true,
  scale:               1,
  paperHeight:         6,
  paperWidth:          4,
  marginTop:           0,
  marginLeft:          0,
  marginRight:         0,
  marginBottom:        0,
  pageRanges:          ''
}
Any progress? I've run into this with printing reports, though I was able to work around the image problem -- it's block of text that I don't have a work around for. Should the text handling be a separate issue?
Any update on this?
Cc: thestig@chromium.org
Components: Internals>Printing
Owner: ----
Status: Available (was: Assigned)
Sounds like a bug in printing, skia or blink.

+thestig for routing.
Cc: chrishtr@chromium.org
+chrishtr to check if this should be treated as dupe of  bug 772685 , see comment #2.
I also posted a similar bug. This one impacts any element which overlaps the wrapping page. Please see:

https://bugs.chromium.org/p/chromium/issues/detail?id=819735

I don't think it is the same as 772685, however not 100% sure.

How do I print with headless to test locally?
Labels: Needs-Bisect
Components: -Internals>Printing Blink>Paint
Status: Untriaged (was: Available)
Hi Chris, I am using node.js with 'Remote Chrome Interface' adapter (https://github.com/cyrus-and/chrome-remote-interface). You can also use Puppeteer to achieve the same (https://github.com/GoogleChrome/puppeteer).

Would it help if I setup an executable nodejs repo?

I've setup a repo for testing Headless issues - Linux + Docker + nodejs. This might save you some time: https://github.com/soncodi/chromium-headless-printtopdf

Please let me know how I can help!

Added a test for reproduction in https://crrev.com/c/955222.

To run, build the headless_browsertests target and then:
# ./headless_browsertests --gtest_filter=*PDFOverflow*

You can trace this test using --trace-startup (to ensure the test runs long enough, simply remove the call to FinishAsynchronousTest(), which will make it time out).
Cc: vamshi.kommuri@chromium.org
As ET team do not have headless setup on Linux to test and confirm this issue as of now.. Requesting for further help in triaging this.

Thanks!
NextAction: 2018-03-19
Status: Available (was: Untriaged)
The Rendering Core team can look after the bisect and/or testing.
Labels: Needs-Feedback
Tried to setup Headless on Linux by following the steps mentioned in https://github.com/soncodi/chromium-headless-printtopdf

After running this command: docker build -t headless, it asked to get docker. We used "sudo apt-get install docker" command to get it. Even after that it says docker isn't available. Attaching the screen cast of the same.

Could someone help us whether the steps followed to setup Headless are correct!

Thanks!
774970-print-to-pdf.mp4
3.2 MB View Download

Comment 27 by asonc...@gmail.com, Mar 12 2018

Hello,

If you have Chrome or Chromium browsers installed, it may be easier to skip Docker altogether. I've just updated the repository with additional run scripts and instructions:
https://github.com/soncodi/chromium-headless-printtopdf



To run Chrome inside Docker instead, the best option is to follow the official guide for Docker CE (https://docs.docker.com/install/linux/docker-ce/ubuntu/) instead of installing from Ubuntu repos.

Note that Docker requires superuser permissions, so you will need to prefix the run script with sudo. Alternately you can run:
sudo usermod -aG docker $USER

and logout/login to run Docker as your current user without sudo.

Comment 28 by asonc...@gmail.com, Mar 12 2018

Issue still appears in nightly Chromium 67.0.3369.0 (64-bit)
Is this the same as 494316 ?
I'd be willing to bet it is indeed the same as 494316. Good call. That one should be easier to debug.

Not marking duplicate yet because we're not sure.
Checked the issue on latest stable 65.0.3325.162 and on 60.0.3072.0 using Ubuntu 14.04 with the below mentioned steps.
1. Downloaded the file provided in https://github.com/soncodi/chromium-headless-printtopdf
2. Unzipped the file to Documents folder
3. Opened terminal and, have run the command git clone https://github.com/soncodi/chromium-headless-printtopdf.git
4. Changed the directory to Documents
5. Then Cd chromium-headless-printtopdf-master
6. npm install
7. ./run-chrome.sh
Observed similar results in folder "Fixture" in both the above mentioned chrome versions. Attaching the screen shots of the same.  

Thanks!
in.html.png
94.4 KB View Download
out.pdf.png
98.1 KB View Download
Owner: schenney@chromium.org
Status: Assigned (was: Available)

Comment 33 by asonc...@gmail.com, Mar 16 2018

The repro shown in the screens above is actually for another print bug I filed: https://bugs.chromium.org/p/chromium/issues/detail?id=819735

It is a very similar issue which may turn out to be a duplicate. Note that both issues can be reproduced using the github repo provided (after changing the input file).
The NextAction date has arrived: 2018-03-19

Comment 35 by asonc...@gmail.com, Mar 27 2018

Hello, any further update? Did the repository help - should I provide additional repros?


I have a fix but it requires testing and more important things have come up.

I'll make every effort to get it into M-66.
Labels: -Needs-Feedback -Needs-Bisect -M-64 -Needs-Triage-M61 M-66
NextAction: ----
Understood, and thank you for your help here. This issue hits our central path so anything I can do to help please let me know!

If it does not make it into M66 - would it be possible to get a dev build with the patch? Thanks again.


Comment 39 by asonc...@gmail.com, Apr 30 2018

Hi, any chance to get a dev/nightly build with this for testing?


Sorry, still working through other regressions. I can't say when I'll get back to this, but it will be soon.
This issue and related https://bugs.chromium.org/p/chromium/issues/detail?id=819735 are impacting a large percentage of our users in production.

This is of critical priority to us. We can help with testing and infrastructure setup. Please let us know what can be done to fast-track this.

Comment 42 by asonc...@gmail.com, Jun 28 2018

Hello, any update on this?
Best estimate right now is a fix for Chrome 69.
Cc: phanindra.mandapaka@chromium.org
Issue 852652 has been merged into this issue.
phanindra.mandapaka@chromium.org -- issue 852652 merged into this one seems unrelated.

Can you also take a look at this one:

https://bugs.chromium.org/p/chromium/issues/detail?id=819735

@schenney which fixes did you think would help to resolve this bug?
I had an attempted fix but it broke some other test case that mstensho@ pointed out broke other content. https://chromium-review.googlesource.com/c/chromium/src/+/1176268

The real fix is to add struts for block level content, but that's bigger. I should un-assign myself unless we consider the other breakage less bad than this breakage, or I limit the proposed fix more tightly.

Sign in to add a comment