qzind / qz-print

Archive for legacy qz-print versions (1.8, 1.9). See https://github.com/qzind/tray for modern versions.
Other
141 stars 101 forks source link

Small margin when printing HTML #143

Closed tresf closed 8 years ago

tresf commented 8 years ago

When printing a full-page HTML document using the HTML printing feature in 2.0, there is a small margin on the right hand side which should not occur.

When reviewing the trace logs (at very bottom of bug report), the width seems to be calculated improperly (594 vs. 650) whereas the height appears to match between image/paper (842)

image

Code to reproduce:

assets/html_sample.html

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<style>

body, html { margin: 0; padding: 0; height: 100%; }
.wrapper { display:table; width: 100%; height: 792px; background-color: purple; }
.div1 { width: 50%; height: 50%; background-color: red; }
.div2 { width: 50%; height: 50%; float: right; background-color: blue; }
.div3 { width: 50%; height: 50%; background-color: green; }

</style>
<body>
<div class="wrapper">
    <div class="div1"></div>
    <div class="div2"></div>
    <div class="div3"></div>
</div>
</body>
</html>

sample.html

    /// Pixel Printers ///
    function printHTML() {
        var config = getUpdatedConfig();

        var printData = [
            {
                type: 'html',
                format: 'file',
                data: 'assets/html_sample.html',
            }
        ];

        qz.print(config, printData).catch(displayError);
    }

Trace log:

[DEBUG] 2016-01-21 02:06:59,096 @ qz.printer.action.PrintHTML:81
    Parsed 1 html records
[TRACE] 2016-01-21 02:06:59,111 @ qz.printer.action.PrintPixel:56
    DPI: 0.0
[TRACE] 2016-01-21 02:06:59,112 @ qz.printer.action.PrintPixel:85
+   Drawable area: 0.0,0.0:594.936,842.04
[TRACE] 2016-01-21 02:06:59,112 @ qz.printer.action.PrintPixel:93
    [color]
[INFO] 2016-01-21 02:06:59,124 @ qz.printer.action.PrintPixel:100
    Starting printing (1 copies)
[TRACE] 2016-01-21 02:06:59,170 @ qz.printer.action.PrintImage:125
    Requested page 0 for printing
[TRACE] 2016-01-21 02:06:59,170 @ qz.printer.action.PrintImage:143
    {Alpha blending interpolation method key=Highest quality alpha blending methods, Color rendering quality key=Highest quality color rendering mode, Stroke normalization control key=Pure stroke conversion for accurate paths, Global rendering quality key=Highest quality rendering methods, Text-specific antialiasing enable key=Default antialiasing text mode, Image interpolation method key=Bicubic image interpolation mode, Global antialiasing enable key=Antialiased rendering mode, Text-specific LCD contrast key=140, Fractional metrics enable key=Integer text metrics mode}
[DEBUG] 2016-01-21 02:06:59,171 @ qz.printer.action.PrintImage:167
+   Paper area: 0,0:594,842
[TRACE] 2016-01-21 02:06:59,171 @ qz.printer.action.PrintImage:168
+   Image size: 650,842
[TRACE] 2016-01-21 02:06:59,209 @ qz.printer.action.PrintImage:125
    Requested page 0 for printing
[TRACE] 2016-01-21 02:06:59,210 @ qz.printer.action.PrintImage:143
    {Alpha blending interpolation method key=Highest quality alpha blending methods, Color rendering quality key=Highest quality color rendering mode, Stroke normalization control key=Pure stroke conversion for accurate paths, Global rendering quality key=Highest quality rendering methods, Text-specific antialiasing enable key=Default antialiasing text mode, Image interpolation method key=Bicubic image interpolation mode, Global antialiasing enable key=Antialiased rendering mode, Text-specific LCD contrast key=140, Fractional metrics enable key=Integer text metrics mode}
[DEBUG] 2016-01-21 02:06:59,211 @ qz.printer.action.PrintImage:167
+   Paper area: 0,0:594,842
[TRACE] 2016-01-21 02:06:59,211 @ qz.printer.action.PrintImage:168
+   Image size: 650,842
[INFO] 2016-01-21 02:06:59,613 @ qz.ws.PrintSocketClient:437
    Printing complete
akberenz commented 8 years ago

Page was still printing as Letter even though page size was set to A4. Fixed via d82ffe0ab1db4ae2cb2a970c49af84711f3a5d6a