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

Issue 741049 link

Starred by 25 users

Issue metadata

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



Sign in to add a comment

Add DPI support for headless chrome printing

Reported by michael....@gmail.com, Jul 11 2017

Issue description

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

Steps to reproduce the problem:
No API to set the DPI of a page when printing to PDF

What is the expected behavior?

What went wrong?
No API provided for the desired functionality

Did this work before? N/A 

Does this work in other browsers? N/A

Chrome version: 59.0.3071.115  Channel: stable
OS Version: OS X 10.12.5
Flash Version: Shockwave Flash 26.0 r0

Related to 603559
 
Cc: pbomm...@chromium.org skyos...@chromium.org jzfeng@chromium.org
Components: Internals>Headless Internals>Skia>PDF
Labels: M-59

Comment 2 by jzfeng@chromium.org, Jul 12 2017

We don't have a DPI setting, since this is not supported in the printing architecture. The images are printed in its original resolution.
Skia folks may be able to advise if there's support for this from their side (or plans to add it).

Comment 4 by hcm@chromium.org, Jul 13 2017

This support is in Skia today (see SkDocument.h), so API could be supported on our side if Chrome was in position to enable...
Cc: thestig@chromium.org
Components: Internals>Printing
Based hcm@ comment tagging with printing and cc'ing Lei for further traige of the bug.
Status: Available (was: Unconfirmed)
Any luck on this?
Labels: -M-59
Owner: thestig@chromium.org
Status: Assigned (was: Available)
Nay. Too many bugs and I lost track of this one. Assigning to myself for too many + 1 bugs. :)
Labels: OS-Linux OS-Windows
Probably feasible, but requires quite a bit of plumbing to get from a user specificed value in the Headless protocol all the way down into the guts of the printing system.
Wow this would be really useful. Text shadows really don't look good without it.

Comment 11 by mmaye...@gmail.com, Mar 29 2018

Agreed - hugely useful to me removing usage of an older unsupported phantomjs version
Any idea how I could fake (force) this in the mean time? I tried recompiling Chromium with #define SK_ScalarDefaultRasterDPI 300.0f in include/code/SkDocument.h, but it didn't have any effect. Next, I will try to use #define SK_PDF_MASK_QUALITY 100 in src/pdf/SkPdfDocument.cpp, but I'll have to wait a few hours to see if it changed anything (man, Chromium takes so much time to compile ;).
It turns out it's not enough because of this:

static bool not_supported_for_layers(const SkPaint& layerPaint) {
    // PDF does not support image filters, so render them on CPU.
    // Note that this rendering is done at "screen" resolution (100dpi), not
    // printer resolution.
    // TODO: It may be possible to express some filters natively using PDF
    // to improve quality and file size (https://bug.skia.org/3043)

    // TODO: should we return true if there is a colorfilter?
    return layerPaint.getImageFilter() != nullptr;
}

Investigating how I could force higher DPI in SKBitmapDevice...
First, let me clarify that I've been producing large (upwards of 1,000 page) PDFs, in volume, for more than 10 years and I'm actively contributing to a number of projects (and building my own) to help others do the same :)

That said, I've been watching Chrome print support grow up since the earliest days, but I've had to use FireFox when printing from browser until just recently, because Chrome was nowhere near ready (and still a ways off compared to Firefox, WKHtmlToPDF, Prince and such), but is making great progress. This DPI issue is one of the other show-stoppers for me and the idea that it's at screen DPI or 100 dpi makes no sense. A 978 page PDF I just generated from Chrome using Print/Save-As-PDF is 40MB while the same one (with downsampling to 150DPI) from WKHTMLTOPDF is < 10MB.

Might they be storing images once, then reusing them (as should be the case per my CSS) to keep the PDF size down? Images look like 100DPI in terms of quality (as others have said), but where is the file size coming from if not the images?

Rendered DPI control is critical to PDF and anyone claiming it's not relevant is somehow missing the graphical half of the media/print world, which is well addressed by other pdf generators.

Sign in to add a comment