Save as PDF ignores print stylesheet when printing selected text
Reported by
andy.bue...@gmail.com,
Sep 25
|
||||||||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0
Steps to reproduce the problem:
1. Select text in a webpage
2. Click print
3. Select "Save as PDF"
4. Check "Selection Only"
What is the expected behavior?
The PDF uses the print stylesheet
What went wrong?
The PDF does not use the print stylesheet
Did this work before? N/A
Chrome version: 69.0.3497.100 Channel: stable
OS Version: 10.0
Flash Version:
Please see attached screenshot, it shows the issue with a tiny sample page:
<html>
<head>
<style>
body {
font-family: Verdana;
}
</style>
<style media="print">
body {
font-family: Times;
}
</style>
</head>
<body>
This is some test text.
</body>
</html>
When i print the whole page then it's fine, font Times is used in the PDF.
But when i select a text to print then the produced PDF apparently ignores the print CSS and uses font Verdana
,
Sep 26
,
Sep 27
Able to reproduce the issue on the latest canary 71.0.3562.0 on Windows-10, same behavior is seen on older chrome version 60.0.3112.20 as well. Triaging this as non-regression issue for furthre investigation. Attaching the html and pdf files for testing this.
,
Sep 27
Sending to thestig@ since this is a printing issue.
,
Oct 30
,
Oct 30
Chrome's printing code calls into Blink via WebLocalFrameImpl::SelectionAsMarkup(), which in term calls Document::UpdateStyleAndLayoutIgnorePendingStylesheets() and FrameSelection::SelectedHTMLForClipboard(). I would suggest adding WebLocalFrameImpl::SelectionAsMarkupForPrinting(), which does something similar to SelectionAsMarkup(), but takes print media CSS into account.
,
Oct 30
Or on the Chrome side, we can enter print mode, and SelectionAsMarkup() will just do the right thing.
,
Nov 10
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/59184f71318ad456c2fd7133209c728e0a2264dc commit 59184f71318ad456c2fd7133209c728e0a2264dc Author: Lei Zhang <thestig@chromium.org> Date: Sat Nov 10 10:02:27 2018 Print selections with print media. PrepareFrameAndViewForPrint::CopySelection() generates HTML + CSS to support printing only the selection. By making it do the generation in print mode, the generated output will have print media CSS applied. BUG= 889226 Change-Id: Ia57d4c0429b93d72cb412545eda7579b53570e6c Reviewed-on: https://chromium-review.googlesource.com/c/1308604 Reviewed-by: Rebekah Potter <rbpotter@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/master@{#607118} [modify] https://crrev.com/59184f71318ad456c2fd7133209c728e0a2264dc/components/printing/renderer/print_render_frame_helper.cc
,
Nov 10
,
Nov 10
Thank you!
,
Nov 12
Able to reproduce the issue on reported chrome version #69.0.3497.100 using Windows 10 by following steps as per comment#0. Verified the fix on Mac 10.14 and Windows 10 on latest chrome #72.0.3608.0. Attached screenshots for reference. Note: Unable to verify fix on Linux as Adobe Acrobat is not getting installed. Thanks.!
,
Nov 13
The fix is already verified on Win and Mac but unable to verify this on Linux as facing issue with Adobe Acrobat installation on Linux. thestig@ Could you please confirm if any alternate PDF tool available on Linux to check the font format so that we can verify the fix on Linux as well. Thanks.!
,
Nov 13
re: comment 12 - any PDF viewer on Linux will be able to verify the output. |
||||||||
►
Sign in to add a comment |
||||||||
Comment 1 by andy.bue...@gmail.com
, Sep 25875 KB
875 KB View Download