qzind / tray

Browser plugin for sending documents and raw commands to a printer or attached device.
https://qz.io
Other
837 stars 273 forks source link

HTML multiple page support #157

Closed tresf closed 6 years ago

tresf commented 7 years ago

Currently in 2.0 and 2.1 HTML printing is limited to a single page of content.

This request is to allow multi-page printing in HTML documents (content which vertically overflows the printable page size).

Here is one technique (the author is handling right-overflow whereas we would want to handle bottom-overflow). http://stackoverflow.com/questions/26785651/javafx-printing-a-node-across-multiple-pages

crazyivan commented 7 years ago

@tresf - this is a critical feature for us. (YesVideo) We'll be very interested in testing and using this feature as soon as it's available.

Do you have a general feel for when 2.1 would be released? i.e. 1 month away vs 6 months away?

tresf commented 7 years ago

@crazyivan about 3 months for a stable release. We'd like to see it for 2.1 as well, but it will depend on how viable the above solution is.

akberenz commented 7 years ago

Available for 2.1 release under 73785a0451888965b80fa2706c28459f8c0bbc95 Includes support for both horizontal and vertical overflow on vector and raster HTML prints. And since raster HTML uses the image processor, it also includes overflow on large (unscaled) images. Horizontal overflow is seen by default on large images, but will only be seen on HTML prints (vector or raster) when the render width is explicitly set, since we default that value to the page width when unset.

shownew

klabarge commented 7 years ago

There seems to be "extra" blank pages used in macOS. After a page is printed with content, a blank page follows. On Windows, printing the exact same HTML page, only 3 pages are printed.

  1. Content
  2. Blank Page
  3. Content
  4. Blank Page
  5. Content
  6. Blank Page

macOS stacktrace, 6 pages printed

[DEBUG] 2017-03-05 19:55:37,420 @ qz.ws.PrintSocketClient:?
    Message: {"call":"print","promise":{},"params":{"printer":{"name":"PDFwriter"},"options":{"colorType":"color","copies":"1","density":"","duplex":false,"fallbackDensity":600,"interpolation":"","jobName":"","margins":"0","orientation":"","paperThickness":"","printerTray":"","rasterize":false,"rotation":"0","scaleContent":false,"size":null,"units":"in","altPrinting":false,"encoding":"","endOfDoc":"","perSpool":"1"},"data":[{"type":"pixel","format":"html","flavor":"file","data":"file:///Users/kyle/Desktop/example.html","options":{"pageWidth":"","pageHeight":""}}]},"timestamp":1488761737417,"uid":"kvcyqi"}
[WARN] 2017-03-05 19:55:37,422 @ qz.ws.PrintSocketClient:?
    Bad signature on request
[ERROR] 2017-03-05 19:55:37,429 @ qz.utils.FileUtilities:?
    Cannot setup file blocked (Shared)
java.io.IOException: No such file or directory
    at java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(File.java:1012)
    at qz.utils.FileUtilities.getFile(Unknown Source)
    at qz.auth.Certificate.isBlocked(Unknown Source)
    at qz.ui.GatewayDialog.prompt(Unknown Source)
    at qz.common.TrayManager.lambda$showGatewayDialog$3(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:109)
    at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:184)
    at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:229)
    at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:227)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:227)
    at java.awt.Dialog.show(Dialog.java:1084)
    at java.awt.Component.show(Component.java:1671)
    at java.awt.Component.setVisible(Component.java:1623)
    at java.awt.Window.setVisible(Window.java:1014)
    at java.awt.Dialog.setVisible(Dialog.java:1005)
    at qz.ui.LogDialog.setVisible(Unknown Source)
    at qz.common.TrayManager$4.actionPerformed(Unknown Source)
    at java.awt.MenuItem.processActionEvent(MenuItem.java:669)
    at java.awt.MenuItem.processEvent(MenuItem.java:628)
    at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:351)
    at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:339)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:761)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.awt.EventQueue$4.run(EventQueue.java:731)
    at java.awt.EventQueue$4.run(EventQueue.java:729)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
[INFO] 2017-03-05 19:55:38,197 @ qz.common.TrayManager:?
    Allowed localhost to print to PDFwriter
[TRACE] 2017-03-05 19:55:38,198 @ qz.utils.PrintingUtilities:?
    Waiting for processor, 0/3 already in use
[DEBUG] 2017-03-05 19:55:38,198 @ qz.utils.PrintingUtilities:?
    Using qz.printer.action.PrintHTML to print
[DEBUG] 2017-03-05 19:55:38,198 @ qz.printer.PrintServiceMatcher:?
    Searching for PrintService matching PDFwriter
[DEBUG] 2017-03-05 19:55:38,199 @ qz.printer.PrintServiceMatcher:?
    Found 3 printers
[DEBUG] 2017-03-05 19:55:38,212 @ qz.printer.PrintServiceMatcher:?
    Found match: PDFwriter
[DEBUG] 2017-03-05 19:55:38,218 @ qz.utils.ShellUtilities:?
    Executing: [lpoptions, -p, zebra, -l]
[DEBUG] 2017-03-05 19:55:38,237 @ qz.utils.ShellUtilities:?
    Executing: [lpoptions, -p, zebra_class, -l]
[DEBUG] 2017-03-05 19:55:38,255 @ qz.utils.ShellUtilities:?
    Executing: [lpoptions, -p, PDFwriter, -l]
[DEBUG] 2017-03-05 19:55:38,275 @ qz.utils.ShellUtilities:?
    Executing: [lpoptions, -p, Zebra_epl, -l]
[DEBUG] 2017-03-05 19:55:38,300 @ qz.printer.action.PrintHTML:?
    Parsed 1 html records
[TRACE] 2017-03-05 19:55:38,312 @ qz.printer.action.PrintHTML:?
     Collation = UNCOLLATED
 Copies = 1
 Sides = ONE_SIDED
 JobName = QZ Tray HTML Print
 Page ranges = null
 Print color = COLOR
 Print quality = NORMAL
 Print resolution = Feed res=300dpi. Cross Feed res=300dpi.
 Paper source = Paper source : Automatic
 Page layout = Paper=Paper: A4 size=210.0x297.0 MM Orient=PORTRAIT leftMargin=0.0 rightMargin=0.0 topMargin=0.0 bottomMargin=0.0
[TRACE] 2017-03-05 19:55:38,313 @ qz.printer.action.WebApp:?
    Waiting on print..
[TRACE] 2017-03-05 19:55:38,313 @ qz.printer.action.WebApp:?
    Setting starting size 816.0:0.0
[TRACE] 2017-03-05 19:55:38,314 @ qz.printer.action.WebApp:?
    Done: 100.0 > -1.0
[TRACE] 2017-03-05 19:55:38,314 @ qz.printer.action.WebApp:?
    New state: SUCCEEDED > READY
[TRACE] 2017-03-05 19:55:38,315 @ qz.printer.action.WebApp:?
    Done: -1.0 > 0.0
[TRACE] 2017-03-05 19:55:38,315 @ qz.printer.action.WebApp:?
    New state: READY > SCHEDULED
[TRACE] 2017-03-05 19:55:38,316 @ qz.printer.action.WebApp:?
    New state: SCHEDULED > RUNNING
[TRACE] 2017-03-05 19:55:38,317 @ qz.printer.action.WebApp:?
    Done: 0.0 > 44.881839472003406
[TRACE] 2017-03-05 19:55:38,324 @ qz.printer.action.WebApp:?
    Done: 44.881839472003406 > 50.0
[TRACE] 2017-03-05 19:55:38,346 @ qz.printer.action.WebApp:?
    Done: 50.0 > 100.0
[TRACE] 2017-03-05 19:55:38,346 @ qz.printer.action.WebApp:?
    New state: RUNNING > SUCCEEDED
[TRACE] 2017-03-05 19:55:38,347 @ qz.printer.action.WebApp:?
    Setting HTML page height to 2835.0
[DEBUG] 2017-03-05 19:55:38,449 @ qz.printer.action.WebApp:?
    Paper area: 0,0:595,842
[DEBUG] 2017-03-05 19:55:38,449 @ qz.printer.action.WebApp:?
    Document will be printed across 6 pages
[INFO] 2017-03-05 19:55:39,315 @ qz.utils.PrintingUtilities:?
    Printing complete
[TRACE] 2017-03-05 19:55:39,316 @ qz.utils.PrintingUtilities:?
    Returning processor back to pool

Windows stacktrace, 3 pages printed

[DEBUG] 2017-03-05 19:39:28,738 @ qz.ws.PrintSocketClient:?
    Message: {"call":"print","promise":{},"params":{"printer":{"name":"PDFCreator"},"options":{"colorType":"color","copies":"1","density":"","duplex":false,"fallbackDensity":600,"interpolation":"","jobName":"","margins":"0","orientation":"","paperThickness":"","printerTray":"","rasterize":false,"rotation":"0","scaleContent":false,"size":null,"units":"in","altPrinting":false,"encoding":"","endOfDoc":"","perSpool":"1"},"data":[{"type":"pixel","format":"html","flavor":"file","data":"file:///C:/Program%20Files/QZ%20Tray/demo/example.html","options":{"pageWidth":"","pageHeight":""}}]},"timestamp":1488760768738,"uid":"jnixzh"}
[WARN] 2017-03-05 19:39:28,744 @ qz.ws.PrintSocketClient:?
    Bad signature on request
[ERROR] 2017-03-05 19:39:28,748 @ qz.utils.FileUtilities:?
    Cannot setup file blocked (Shared)
java.io.IOException: The system cannot find the path specified
    at java.io.WinNTFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(Unknown Source)
    at qz.utils.FileUtilities.getFile(Unknown Source)
    at qz.auth.Certificate.isBlocked(Unknown Source)
    at qz.ui.GatewayDialog.prompt(Unknown Source)
    at qz.common.TrayManager.lambda$showGatewayDialog$3(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.WaitDispatchSupport$2.run(Unknown Source)
    at java.awt.WaitDispatchSupport$4.run(Unknown Source)
    at java.awt.WaitDispatchSupport$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.WaitDispatchSupport.enter(Unknown Source)
    at java.awt.Dialog.show(Unknown Source)
    at java.awt.Component.show(Unknown Source)
    at java.awt.Component.setVisible(Unknown Source)
    at java.awt.Window.setVisible(Unknown Source)
    at java.awt.Dialog.setVisible(Unknown Source)
    at qz.ui.LogDialog.setVisible(Unknown Source)
    at qz.common.TrayManager$4.actionPerformed(Unknown Source)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.AbstractButton.doClick(Unknown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
[INFO] 2017-03-05 19:39:29,817 @ qz.common.TrayManager:?
    Allowed localhost to print to PDFCreator
[TRACE] 2017-03-05 19:39:29,818 @ qz.utils.PrintingUtilities:?
    Waiting for processor, 0/7 already in use
[DEBUG] 2017-03-05 19:39:29,819 @ qz.utils.PrintingUtilities:?
    Using qz.printer.action.PrintHTML to print
[DEBUG] 2017-03-05 19:39:29,819 @ qz.printer.PrintServiceMatcher:?
    Searching for PrintService matching PDFCreator
[DEBUG] 2017-03-05 19:39:29,820 @ qz.printer.PrintServiceMatcher:?
    Found 11 printers
[DEBUG] 2017-03-05 19:39:29,820 @ qz.printer.PrintServiceMatcher:?
    Found match: PDFCreator
[DEBUG] 2017-03-05 19:39:29,820 @ qz.utils.PrintingUtilities:?
    Found Resolution: 60000x60000 dphi
[DEBUG] 2017-03-05 19:39:29,829 @ qz.printer.action.PrintHTML:?
    Parsed 1 html records
[TRACE] 2017-03-05 19:39:29,837 @ qz.printer.action.PrintHTML:?
     Collation = COLLATED
 Copies = 1
 Sides = ONE_SIDED
 JobName = QZ Tray HTML Print
 Page ranges = null
 Print color = COLOR
 Print quality = NORMAL
 Print resolution = Feed res=600dpi. Cross Feed res=600dpi.
 Paper source = Paper source : Automatic
 Page layout = Paper=Paper: Letter size=8.5x11.0 INCH Orient=PORTRAIT leftMargin=0.0 rightMargin=0.0 topMargin=0.0 bottomMargin=0.0
[TRACE] 2017-03-05 19:39:29,843 @ qz.printer.action.WebApp:?
    Waiting on print..
[TRACE] 2017-03-05 19:39:29,843 @ qz.printer.action.WebApp:?
    Setting starting size 816.0:0.0
[TRACE] 2017-03-05 19:39:29,846 @ qz.printer.action.WebApp:?
    Done: 100.0 > -1.0
[TRACE] 2017-03-05 19:39:29,847 @ qz.printer.action.WebApp:?
    New state: SUCCEEDED > READY
[TRACE] 2017-03-05 19:39:29,850 @ qz.printer.action.WebApp:?
    Done: -1.0 > 0.0
[TRACE] 2017-03-05 19:39:29,851 @ qz.printer.action.WebApp:?
    New state: READY > SCHEDULED
[TRACE] 2017-03-05 19:39:29,851 @ qz.printer.action.WebApp:?
    New state: SCHEDULED > RUNNING
[TRACE] 2017-03-05 19:39:29,854 @ qz.printer.action.WebApp:?
    Done: 0.0 > 44.881839472003406
[TRACE] 2017-03-05 19:39:29,880 @ qz.printer.action.WebApp:?
    Done: 44.881839472003406 > 100.0
[TRACE] 2017-03-05 19:39:29,881 @ qz.printer.action.WebApp:?
    New state: RUNNING > SUCCEEDED
[TRACE] 2017-03-05 19:39:29,883 @ qz.printer.action.WebApp:?
    Setting HTML page height to 2835.0
[DEBUG] 2017-03-05 19:39:30,000 @ qz.printer.action.WebApp:?
    Paper area: 0,0:612,792
[DEBUG] 2017-03-05 19:39:30,001 @ qz.printer.action.WebApp:?
    Document will be printed across 3 pages
[INFO] 2017-03-05 19:39:30,844 @ qz.utils.PrintingUtilities:?
    Printing complete
[TRACE] 2017-03-05 19:39:30,845 @ qz.utils.PrintingUtilities:?
    Returning processor back to pool
akberenz commented 7 years ago

@klabarge, what is your default printer (and settings) on the osx machine?

Page layout = Paper=Paper: A4 size=210.0x297.0 MM Orient=PORTRAIT leftMargin=0.0 rightMargin=0.0 topMargin=0.0 bottomMargin=0.0 [TRACE] 2017-03-05 19:55:38,313 @ qz.printer.action.WebApp:? Waiting on print.. [TRACE] 2017-03-05 19:55:38,313 @ qz.printer.action.WebApp:? Setting starting size 816.0:0.0

From the logs, it looks like it is using an 8.5in width (816px) to render on a 8.3in (793px) width paper, resulting in the extra pages. But I can't seem to figure out why.

tresf commented 7 years ago

@bberenz shot in the dark, but is there a chance this is an unobvious duplicate of #174?

akberenz commented 7 years ago

@tresf, possible, but doubtful. It appears the print used all defaults (no attributes set), and the the paper size wasn't overridden, so A4 should have been the printer default anyway.

klabarge commented 7 years ago

My default printer is PDFwriter.

After I changed the CUPS default to US Letter, 3 pages were correctly printed. I then tested the various combinations. The only combination that did not print correctly, was when CUPS was set to A4, and the System Settings were set to US Letter.

Note that I had to restart QZ Tray for the settings to change between each CUPS/System printer change.

Let me know what additional information you need me to provide

akberenz commented 7 years ago

It looks like javaFX uses the settings under CUPS then, while Swing uses System settings. We set the default html page width from Swing to Letter (8.5in), the vector print runs and sets page size from JavaFX to A4 (8.3in) and it thinks it has to split the width across multiple pages.

To confirm, @klabarge, when you print images or pdfs, it defaults to the System page settings and ignores CUPS's page setting, right?

tresf commented 7 years ago

Kyle was having trouble reproducing his problem so I decided to try on my machine... I have a problem...

Horizontal overflow is seen by default on large images, but will only be seen on HTML prints (vector or raster) when the render width is explicitly set, since we default that value to the page width when unset.

Using sample.html, when I set Render Width: 8.27, the following occurs in the logs...

The test page I'm printing is available here: https://gist.github.com/tresf/0e9a448901c46f51cdc2efb659d39057

The page seems to print OK without Render Width specified.

[TRACE] 2017-05-02 00:16:34,880 @ qz.printer.action.PrintHTML:?
     Collation = UNCOLLATED
 Copies = 1
 Sides = ONE_SIDED
 JobName = QZ Tray HTML Print
 Page ranges = null
 Print color = COLOR
 Print quality = NORMAL
 Print resolution = Feed res=300dpi. Cross Feed res=300dpi.
 Paper source = Paper source : Automatic
 Page layout = Paper=Paper: Letter size=8.5x11.0 INCH Orient=PORTRAIT leftMargin=0.0 rightMargin=0.0 topMargin=0.0 bottomMargin=0.0
[TRACE] 2017-05-02 00:16:34,880 @ qz.printer.action.WebApp:?
    Waiting on print..
[TRACE] 2017-05-02 00:16:34,880 @ qz.printer.action.WebApp:?
    Setting starting size 793.9199999999998:NaN
[TRACE] 2017-05-02 00:16:34,880 @ qz.printer.action.WebApp:?
    Done: 100.0 > -1.0
[TRACE] 2017-05-02 00:16:34,880 @ qz.printer.action.WebApp:?
    New state: SUCCEEDED > READY
[TRACE] 2017-05-02 00:16:34,881 @ qz.printer.action.WebApp:?
    Done: -1.0 > 0.0
[TRACE] 2017-05-02 00:16:34,881 @ qz.printer.action.WebApp:?
    New state: READY > SCHEDULED
[TRACE] 2017-05-02 00:16:34,881 @ qz.printer.action.WebApp:?
    New state: SCHEDULED > RUNNING
[TRACE] 2017-05-02 00:16:34,882 @ qz.printer.action.WebApp:?
    Done: 0.0 > 34.957728456745926
[TRACE] 2017-05-02 00:16:34,908 @ qz.printer.action.WebApp:?
    Done: 34.957728456745926 > 100.0
[TRACE] 2017-05-02 00:16:34,908 @ qz.printer.action.WebApp:?
    New state: RUNNING > SUCCEEDED
[DEBUG] 2017-05-02 00:16:35,024 @ qz.printer.action.WebApp:?
    Paper area: 0,0:612,792
[DEBUG] 2017-05-02 00:16:35,024 @ qz.printer.action.WebApp:?
    Document will be printed across 0 pages
[INFO] 2017-05-02 00:16:35,884 @ qz.utils.PrintingUtilities:?
    Printing complete
[TRACE] 2017-05-02 00:16:35,885 @ qz.utils.PrintingUtilities:?
    Returning processor back to pool
akberenz commented 7 years ago

Setting starting size 793.9199999999998:NaN

Can you try setting a render height as well? It looks like the sample page might not be using the right default if only one render dimension is used.

tresf commented 7 years ago

Can you try setting a render height as well?

Sure, here's the output using 8.27 x 11.69. Here are the sample.html options.

 Copies = 1
 Sides = ONE_SIDED
 JobName = QZ Tray HTML Print
 Page ranges = null
 Print color = COLOR
 Print quality = NORMAL
 Print resolution = Feed res=300dpi. Cross Feed res=300dpi.
 Paper source = Paper source : Automatic
 Page layout = Paper=Paper: Letter size=8.5x11.0 INCH Orient=PORTRAIT leftMargin=0.0 rightMargin=0.0 topMargin=0.0 bottomMargin=0.0
[TRACE] 2017-05-02 00:51:58,776 @ qz.printer.action.WebApp:?
    Waiting on print..
[TRACE] 2017-05-02 00:51:58,777 @ qz.printer.action.WebApp:?
    Setting starting size 793.9199999999998:1122.2399999999998
[TRACE] 2017-05-02 00:51:58,829 @ qz.printer.action.WebApp:?
    Done: -1.0 > 0.0
[TRACE] 2017-05-02 00:51:58,829 @ qz.printer.action.WebApp:?
    New state: READY > SCHEDULED
[TRACE] 2017-05-02 00:51:58,829 @ qz.printer.action.WebApp:?
    New state: SCHEDULED > RUNNING
[TRACE] 2017-05-02 00:51:58,852 @ qz.printer.action.WebApp:?
    Done: 0.0 > 34.957728456745926
[TRACE] 2017-05-02 00:51:59,063 @ qz.printer.action.WebApp:?
    Done: 34.957728456745926 > 100.0
[TRACE] 2017-05-02 00:51:59,063 @ qz.printer.action.WebApp:?
    New state: RUNNING > SUCCEEDED
[DEBUG] 2017-05-02 00:51:59,272 @ qz.printer.action.WebApp:?
    Paper area: 0,0:612,792
[DEBUG] 2017-05-02 00:51:59,273 @ qz.printer.action.WebApp:?
    Document will be printed across 2 pages
[INFO] 2017-05-02 00:51:59,780 @ qz.utils.PrintingUtilities:?
    Printing complete
[TRACE] 2017-05-02 00:51:59,781 @ qz.utils.PrintingUtilities:?
    Returning processor back to pool
tresf commented 7 years ago

@bberenz recommends:

can you report the results of changing this line (https://github.com/qzind/tray/blob/2.1/src/qz/printer/action/PrintHTML.java#L144) to: Paper paper = fxPrinter.getDefaultPageLayout().getPaper(); It looks like this might be where the disparity between swing & javafx comes from

Will test and report back.

crispconcepts commented 7 years ago

Is this resolved in the 2.1 branch?

It still doesn't appear to be printing multiple HTML pages for me using the following function:

function printPackslip(invoice_id, test=false) {
    // console.log("printPackslip("+invoice_id+") started");
    var printer_packslip=getCookieInfo('setPrinterPackslip');
    var config = qz.configs.create(printer_packslip);// Exact printer name from OS
    // get packing slip
    $.get( "invoice_print.php", { 'print':'y', 'screen':'244', 'invoiceset':invoice_id }, function(packingslipfile){
        var printData = [{ type:'html', format:'plain', data:packingslipfile }];
        // console.log(printData);
        qz.print(config, printData).then(function(){
            if(test) statusAlert("Packing Slip Printed");
        }).catch(function(e){
            if(test) statusAlert("Packing Slip Print Failed");
            console.log(e);
        });
    });
}
akberenz commented 7 years ago

@ljacobs-sml, no it is not. We are still waiting on testing to resolve a sizing error on macOS. This issue will be closed when we believe it is resolved.

In regards to your bit of code, you need to keep a couple of things in mind:

klabarge commented 7 years ago

Edit: This is on macOS

(https://github.com/qzind/tray/blob/2.1/src/qz/printer/action/PrintHTML.java#L144) to: Paper paper = fxPrinter.getDefaultPageLayout().getPaper();

Here are the logs after printing using a Render Width and Render Height of 8.27 x 11.69

Before Change

[DEBUG] 2017-07-12 00:05:10,481 @ qz.ws.PrintSocketClient:164
    Message: {"call":"print","promise":{},"params":{"printer":{"name":"PDFwriter"},"options":{"colorType":"color","copies":"1","density":"","duplex":false,"fallbackDensity":null,"interpolation":"","jobName":"","margins":"0","orientation":"","paperThickness":"","printerTray":"","rasterize":false,"rotation":"0","scaleContent":false,"size":null,"units":"in","altPrinting":false,"encoding":"","endOfDoc":"","perSpool":"1"},"data":[{"type":"pixel","format":"html","flavor":"file","data":"file:///Applications/QZ%20Tray.app/demo/foo.html","options":{"pageWidth":"8.27","pageHeight":"11.69"}}]},"timestamp":1499832310475,"uid":"44by1i"}
[WARN] 2017-07-12 00:05:10,482 @ qz.ws.PrintSocketClient:202
    Bad signature on request
[INFO] 2017-07-12 00:05:11,485 @ qz.common.TrayManager:397
    Allowed localhost to print to PDFwriter
[TRACE] 2017-07-12 00:05:11,486 @ qz.utils.PrintingUtilities:79
    Waiting for processor, 0/3 already in use
[DEBUG] 2017-07-12 00:05:11,486 @ qz.utils.PrintingUtilities:227
    Using qz.printer.action.PrintHTML to print
[DEBUG] 2017-07-12 00:05:11,486 @ qz.printer.PrintServiceMatcher:59
    Searching for PrintService matching PDFwriter
[DEBUG] 2017-07-12 00:05:11,486 @ qz.printer.PrintServiceMatcher:34
    Found 5 printers
[DEBUG] 2017-07-12 00:05:11,503 @ qz.printer.PrintServiceMatcher:110
    Found match: PDFwriter
[DEBUG] 2017-07-12 00:05:11,508 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, zebra, -l]
[DEBUG] 2017-07-12 00:05:11,527 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, zebra_class, -l]
[DEBUG] 2017-07-12 00:05:11,546 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, Print_to_VipRiser, -l]
[DEBUG] 2017-07-12 00:05:11,565 @ qz.utils.ShellUtilities:236
    Parsed default density from CUPS Print_to_VipRiser: 72dpi
[DEBUG] 2017-07-12 00:05:11,565 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, CUPS_PDF, -l]
[DEBUG] 2017-07-12 00:05:11,583 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, PDFwriter, -l]
[DEBUG] 2017-07-12 00:05:11,600 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, Zebra_epl, -l]
[DEBUG] 2017-07-12 00:05:11,617 @ qz.utils.ShellUtilities:236
    Parsed default density from CUPS Zebra_epl: 203dpi
[WARN] 2017-07-12 00:05:11,617 @ qz.printer.PrintOptions:252
    Cannot read null as a double for fallbackDensity, using default
[DEBUG] 2017-07-12 00:05:11,626 @ qz.printer.action.PrintHTML:85
    Parsed 1 html records
[TRACE] 2017-07-12 00:05:11,649 @ qz.printer.action.PrintHTML:190
     Collation = UNCOLLATED
 Copies = 1
 Sides = ONE_SIDED
 JobName = QZ Tray HTML Print
 Page ranges = null
 Print color = COLOR
 Print quality = NORMAL
 Print resolution = Feed res=300dpi. Cross Feed res=300dpi.
 Paper source = Paper source : Automatic
 Page layout = Paper=Paper: A4 size=210.0x297.0 MM Orient=PORTRAIT leftMargin=0.0 rightMargin=0.0 topMargin=0.0 bottomMargin=0.0
[TRACE] 2017-07-12 00:05:11,649 @ qz.printer.action.WebApp:192
    Waiting on print..
[TRACE] 2017-07-12 00:05:11,649 @ qz.printer.action.WebApp:244
    Setting starting size 793.9199999999998:1122.2399999999998
[TRACE] 2017-07-12 00:05:11,649 @ qz.printer.action.WebApp:97
    Done: 100.0 > -1.0
[TRACE] 2017-07-12 00:05:11,649 @ qz.printer.action.WebApp:61
    New state: SUCCEEDED > READY
[TRACE] 2017-07-12 00:05:11,650 @ qz.printer.action.WebApp:97
    Done: -1.0 > 0.0
[TRACE] 2017-07-12 00:05:11,650 @ qz.printer.action.WebApp:61
    New state: READY > SCHEDULED
[TRACE] 2017-07-12 00:05:11,650 @ qz.printer.action.WebApp:61
    New state: SCHEDULED > RUNNING
[TRACE] 2017-07-12 00:05:11,652 @ qz.printer.action.WebApp:97
    Done: 0.0 > 34.957728456745926
[TRACE] 2017-07-12 00:05:11,656 @ qz.printer.action.WebApp:97
    Done: 34.957728456745926 > 50.0
[TRACE] 2017-07-12 00:05:11,669 @ qz.printer.action.WebApp:97
    Done: 50.0 > 100.0
[TRACE] 2017-07-12 00:05:11,669 @ qz.printer.action.WebApp:61
    New state: RUNNING > SUCCEEDED
[DEBUG] 2017-07-12 00:05:11,782 @ qz.printer.action.WebApp:161
    Paper area: 0,0:595,842
[DEBUG] 2017-07-12 00:05:11,782 @ qz.printer.action.WebApp:169
    Document will be printed across 2 pages
[INFO] 2017-07-12 00:05:12,654 @ qz.utils.PrintingUtilities:235
    Printing complete
[TRACE] 2017-07-12 00:05:12,654 @ qz.utils.PrintingUtilities:119
    Returning processor back to pool

After change

    Message: {"call":"print","promise":{},"params":{"printer":{"name":"PDFwriter"},"options":{"colorType":"color","copies":"1","density":"","duplex":false,"fallbackDensity":null,"interpolation":"","jobName":"","margins":"0","orientation":"","paperThickness":"","printerTray":"","rasterize":false,"rotation":"0","scaleContent":false,"size":null,"units":"in","altPrinting":false,"encoding":"","endOfDoc":"","perSpool":"1"},"data":[{"type":"pixel","format":"html","flavor":"file","data":"file:///Applications/QZ%20Tray.app/demo/foo.html","options":{"pageWidth":"","pageHeight":""}}]},"timestamp":1499832447202,"uid":"jxyzve"}
[WARN] 2017-07-12 00:07:27,206 @ qz.ws.PrintSocketClient:202
    Bad signature on request
[INFO] 2017-07-12 00:07:28,059 @ qz.common.TrayManager:397
    Allowed localhost to print to PDFwriter
[TRACE] 2017-07-12 00:07:28,059 @ qz.utils.PrintingUtilities:79
    Waiting for processor, 0/3 already in use
[DEBUG] 2017-07-12 00:07:28,059 @ qz.utils.PrintingUtilities:227
    Using qz.printer.action.PrintHTML to print
[DEBUG] 2017-07-12 00:07:28,059 @ qz.printer.PrintServiceMatcher:59
    Searching for PrintService matching PDFwriter
[DEBUG] 2017-07-12 00:07:28,059 @ qz.printer.PrintServiceMatcher:34
    Found 5 printers
[DEBUG] 2017-07-12 00:07:28,072 @ qz.printer.PrintServiceMatcher:110
    Found match: PDFwriter
[DEBUG] 2017-07-12 00:07:28,077 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, zebra, -l]
[DEBUG] 2017-07-12 00:07:28,092 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, zebra_class, -l]
[DEBUG] 2017-07-12 00:07:28,108 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, Print_to_VipRiser, -l]
[DEBUG] 2017-07-12 00:07:28,123 @ qz.utils.ShellUtilities:236
    Parsed default density from CUPS Print_to_VipRiser: 72dpi
[DEBUG] 2017-07-12 00:07:28,123 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, CUPS_PDF, -l]
[DEBUG] 2017-07-12 00:07:28,140 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, PDFwriter, -l]
[DEBUG] 2017-07-12 00:07:28,157 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, Zebra_epl, -l]
[DEBUG] 2017-07-12 00:07:28,174 @ qz.utils.ShellUtilities:236
    Parsed default density from CUPS Zebra_epl: 203dpi
[WARN] 2017-07-12 00:07:28,174 @ qz.printer.PrintOptions:252
    Cannot read null as a double for fallbackDensity, using default
[DEBUG] 2017-07-12 00:07:28,183 @ qz.printer.action.PrintHTML:85
    Parsed 1 html records
[TRACE] 2017-07-12 00:07:28,202 @ qz.printer.action.PrintHTML:190
     Collation = UNCOLLATED
 Copies = 1
 Sides = ONE_SIDED
 JobName = QZ Tray HTML Print
 Page ranges = null
 Print color = COLOR
 Print quality = NORMAL
 Print resolution = Feed res=300dpi. Cross Feed res=300dpi.
 Paper source = Paper source : Automatic
 Page layout = Paper=Paper: A4 size=210.0x297.0 MM Orient=PORTRAIT leftMargin=0.0 rightMargin=0.0 topMargin=0.0 bottomMargin=0.0
[TRACE] 2017-07-12 00:07:28,202 @ qz.printer.action.WebApp:192
    Waiting on print..
[TRACE] 2017-07-12 00:07:28,202 @ qz.printer.action.WebApp:244
    Setting starting size 793.3333333333333:0.0
[TRACE] 2017-07-12 00:07:28,202 @ qz.printer.action.WebApp:97
    Done: 100.0 > -1.0
[TRACE] 2017-07-12 00:07:28,203 @ qz.printer.action.WebApp:61
    New state: SUCCEEDED > READY
[TRACE] 2017-07-12 00:07:28,203 @ qz.printer.action.WebApp:97
    Done: -1.0 > 0.0
[TRACE] 2017-07-12 00:07:28,203 @ qz.printer.action.WebApp:61
    New state: READY > SCHEDULED
[TRACE] 2017-07-12 00:07:28,203 @ qz.printer.action.WebApp:61
    New state: SCHEDULED > RUNNING
[TRACE] 2017-07-12 00:07:28,204 @ qz.printer.action.WebApp:97
    Done: 0.0 > 34.957728456745926
[TRACE] 2017-07-12 00:07:28,209 @ qz.printer.action.WebApp:97
    Done: 34.957728456745926 > 50.0
[TRACE] 2017-07-12 00:07:28,223 @ qz.printer.action.WebApp:97
    Done: 50.0 > 100.0
[TRACE] 2017-07-12 00:07:28,223 @ qz.printer.action.WebApp:61
    New state: RUNNING > SUCCEEDED
[TRACE] 2017-07-12 00:07:28,224 @ qz.printer.action.WebApp:82
    Setting HTML page height to 1940.0
[DEBUG] 2017-07-12 00:07:28,338 @ qz.printer.action.WebApp:161
    Paper area: 0,0:595,842
[DEBUG] 2017-07-12 00:07:28,339 @ qz.printer.action.WebApp:169
    Document will be printed across 2 pages
[INFO] 2017-07-12 00:07:29,207 @ qz.utils.PrintingUtilities:235
    Printing complete
[TRACE] 2017-07-12 00:07:29,208 @ qz.utils.PrintingUtilities:119
    Returning processor back to pool

I also noticed there is definitely a bug with HTML printing on macOS:

Whenever I change the Render Width and Render Height, the first print job is blank.

  1. Print HTML page(s)
    • Verify it prints correctly
  2. Change the Render Width and Render Height to 8.5 x 11.7 in and print
    • Page printed is 1kb
  3. Print HTML page again
    • Verify it prints correctly

print 1, blank page

[DEBUG] 2017-07-11 23:51:01,112 @ qz.ws.PrintSocketClient:164
    Message: {"call":"print","promise":{},"params":{"printer":{"name":"PDFwriter"},"options":{"colorType":"color","copies":"1","density":"","duplex":false,"fallbackDensity":null,"interpolation":"","jobName":"","margins":"0","orientation":"","paperThickness":"","printerTray":"","rasterize":false,"rotation":"0","scaleContent":false,"size":null,"units":"in","altPrinting":false,"encoding":"","endOfDoc":"","perSpool":"1"},"data":[{"type":"pixel","format":"html","flavor":"file","data":"file:///Applications/QZ%20Tray.app/demo/foo.html","options":{"pageWidth":"8.5","pageHeight":"11.7"}}]},"timestamp":1499831461110,"uid":"5bbgm8"}
[WARN] 2017-07-11 23:51:01,112 @ qz.ws.PrintSocketClient:202
    Bad signature on request
[INFO] 2017-07-11 23:51:02,053 @ qz.common.TrayManager:397
    Allowed localhost to print to PDFwriter
[TRACE] 2017-07-11 23:51:02,053 @ qz.utils.PrintingUtilities:79
    Waiting for processor, 0/3 already in use
[DEBUG] 2017-07-11 23:51:02,053 @ qz.utils.PrintingUtilities:227
    Using qz.printer.action.PrintHTML to print
[DEBUG] 2017-07-11 23:51:02,053 @ qz.printer.PrintServiceMatcher:59
    Searching for PrintService matching PDFwriter
[DEBUG] 2017-07-11 23:51:02,053 @ qz.printer.PrintServiceMatcher:34
    Found 5 printers
[DEBUG] 2017-07-11 23:51:02,066 @ qz.printer.PrintServiceMatcher:110
    Found match: PDFwriter
[DEBUG] 2017-07-11 23:51:02,070 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, zebra, -l]
[DEBUG] 2017-07-11 23:51:02,086 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, zebra_class, -l]
[DEBUG] 2017-07-11 23:51:02,102 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, Print_to_VipRiser, -l]
[DEBUG] 2017-07-11 23:51:02,118 @ qz.utils.ShellUtilities:236
    Parsed default density from CUPS Print_to_VipRiser: 72dpi
[DEBUG] 2017-07-11 23:51:02,119 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, CUPS_PDF, -l]
[DEBUG] 2017-07-11 23:51:02,135 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, PDFwriter, -l]
[DEBUG] 2017-07-11 23:51:02,151 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, Zebra_epl, -l]
[DEBUG] 2017-07-11 23:51:02,168 @ qz.utils.ShellUtilities:236
    Parsed default density from CUPS Zebra_epl: 203dpi
[WARN] 2017-07-11 23:51:02,168 @ qz.printer.PrintOptions:252
    Cannot read null as a double for fallbackDensity, using default
[DEBUG] 2017-07-11 23:51:02,177 @ qz.printer.action.PrintHTML:85
    Parsed 1 html records
[TRACE] 2017-07-11 23:51:02,194 @ qz.printer.action.PrintHTML:190
     Collation = UNCOLLATED
 Copies = 1
 Sides = ONE_SIDED
 JobName = QZ Tray HTML Print
 Page ranges = null
 Print color = COLOR
 Print quality = NORMAL
 Print resolution = Feed res=300dpi. Cross Feed res=300dpi.
 Paper source = Paper source : Automatic
 Page layout = Paper=Paper: Letter size=8.5x11.0 INCH Orient=PORTRAIT leftMargin=0.0 rightMargin=0.0 topMargin=0.0 bottomMargin=0.0
[TRACE] 2017-07-11 23:51:02,194 @ qz.printer.action.WebApp:192
    Waiting on print..
[TRACE] 2017-07-11 23:51:02,194 @ qz.printer.action.WebApp:244
    Setting starting size 816.0:1123.1999999999998
[TRACE] 2017-07-11 23:51:02,195 @ qz.printer.action.WebApp:97
    Done: 100.0 > -1.0
[TRACE] 2017-07-11 23:51:02,195 @ qz.printer.action.WebApp:61
    New state: SUCCEEDED > READY
[TRACE] 2017-07-11 23:51:02,195 @ qz.printer.action.WebApp:97
    Done: -1.0 > 0.0
[TRACE] 2017-07-11 23:51:02,195 @ qz.printer.action.WebApp:61
    New state: READY > SCHEDULED
[TRACE] 2017-07-11 23:51:02,195 @ qz.printer.action.WebApp:61
    New state: SCHEDULED > RUNNING
[TRACE] 2017-07-11 23:51:02,196 @ qz.printer.action.WebApp:97
    Done: 0.0 > 34.957728456745926
[TRACE] 2017-07-11 23:51:02,201 @ qz.printer.action.WebApp:97
    Done: 34.957728456745926 > 50.0
[TRACE] 2017-07-11 23:51:02,214 @ qz.printer.action.WebApp:97
    Done: 50.0 > 100.0
[TRACE] 2017-07-11 23:51:02,214 @ qz.printer.action.WebApp:61
    New state: RUNNING > SUCCEEDED
[DEBUG] 2017-07-11 23:51:02,330 @ qz.printer.action.WebApp:161
    Paper area: 0,0:612,792
[DEBUG] 2017-07-11 23:51:02,330 @ qz.printer.action.WebApp:169
    Document will be printed across 2 pages
[INFO] 2017-07-11 23:51:03,196 @ qz.utils.PrintingUtilities:235
    Printing complete
[TRACE] 2017-07-11 23:51:03,197 @ qz.utils.PrintingUtilities:119
    Returning processor back to pool

print 2, correct print

[DEBUG] 2017-07-11 23:51:14,980 @ qz.ws.PrintSocketClient:164
    Message: {"call":"print","promise":{},"params":{"printer":{"name":"PDFwriter"},"options":{"colorType":"color","copies":"1","density":"","duplex":false,"fallbackDensity":null,"interpolation":"","jobName":"","margins":"0","orientation":"","paperThickness":"","printerTray":"","rasterize":false,"rotation":"0","scaleContent":false,"size":null,"units":"in","altPrinting":false,"encoding":"","endOfDoc":"","perSpool":"1"},"data":[{"type":"pixel","format":"html","flavor":"file","data":"file:///Applications/QZ%20Tray.app/demo/foo.html","options":{"pageWidth":"8.5","pageHeight":"11.7"}}]},"timestamp":1499831474979,"uid":"4h71bm"}
[WARN] 2017-07-11 23:51:14,980 @ qz.ws.PrintSocketClient:202
    Bad signature on request
[INFO] 2017-07-11 23:51:17,053 @ qz.common.TrayManager:397
    Allowed localhost to print to PDFwriter
[TRACE] 2017-07-11 23:51:17,054 @ qz.utils.PrintingUtilities:79
    Waiting for processor, 0/3 already in use
[DEBUG] 2017-07-11 23:51:17,054 @ qz.utils.PrintingUtilities:227
    Using qz.printer.action.PrintHTML to print
[DEBUG] 2017-07-11 23:51:17,054 @ qz.printer.PrintServiceMatcher:59
    Searching for PrintService matching PDFwriter
[DEBUG] 2017-07-11 23:51:17,054 @ qz.printer.PrintServiceMatcher:34
    Found 5 printers
[DEBUG] 2017-07-11 23:51:17,067 @ qz.printer.PrintServiceMatcher:110
    Found match: PDFwriter
[DEBUG] 2017-07-11 23:51:17,072 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, zebra, -l]
[DEBUG] 2017-07-11 23:51:17,088 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, zebra_class, -l]
[DEBUG] 2017-07-11 23:51:17,105 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, Print_to_VipRiser, -l]
[DEBUG] 2017-07-11 23:51:17,121 @ qz.utils.ShellUtilities:236
    Parsed default density from CUPS Print_to_VipRiser: 72dpi
[DEBUG] 2017-07-11 23:51:17,121 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, CUPS_PDF, -l]
[DEBUG] 2017-07-11 23:51:17,137 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, PDFwriter, -l]
[DEBUG] 2017-07-11 23:51:17,154 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, Zebra_epl, -l]
[DEBUG] 2017-07-11 23:51:17,171 @ qz.utils.ShellUtilities:236
    Parsed default density from CUPS Zebra_epl: 203dpi
[WARN] 2017-07-11 23:51:17,171 @ qz.printer.PrintOptions:252
    Cannot read null as a double for fallbackDensity, using default
[DEBUG] 2017-07-11 23:51:17,179 @ qz.printer.action.PrintHTML:85
    Parsed 1 html records
[TRACE] 2017-07-11 23:51:17,196 @ qz.printer.action.PrintHTML:190
     Collation = UNCOLLATED
 Copies = 1
 Sides = ONE_SIDED
 JobName = QZ Tray HTML Print
 Page ranges = null
 Print color = COLOR
 Print quality = NORMAL
 Print resolution = Feed res=300dpi. Cross Feed res=300dpi.
 Paper source = Paper source : Automatic
 Page layout = Paper=Paper: Letter size=8.5x11.0 INCH Orient=PORTRAIT leftMargin=0.0 rightMargin=0.0 topMargin=0.0 bottomMargin=0.0
[TRACE] 2017-07-11 23:51:17,196 @ qz.printer.action.WebApp:192
    Waiting on print..
[TRACE] 2017-07-11 23:51:17,196 @ qz.printer.action.WebApp:244
    Setting starting size 816.0:1123.1999999999998
[TRACE] 2017-07-11 23:51:17,197 @ qz.printer.action.WebApp:97
    Done: 100.0 > -1.0
[TRACE] 2017-07-11 23:51:17,197 @ qz.printer.action.WebApp:61
    New state: SUCCEEDED > READY
[TRACE] 2017-07-11 23:51:17,197 @ qz.printer.action.WebApp:97
    Done: -1.0 > 0.0
[TRACE] 2017-07-11 23:51:17,197 @ qz.printer.action.WebApp:61
    New state: READY > SCHEDULED
[TRACE] 2017-07-11 23:51:17,197 @ qz.printer.action.WebApp:61
    New state: SCHEDULED > RUNNING
[TRACE] 2017-07-11 23:51:17,198 @ qz.printer.action.WebApp:97
    Done: 0.0 > 34.957728456745926
[TRACE] 2017-07-11 23:51:17,203 @ qz.printer.action.WebApp:97
    Done: 34.957728456745926 > 50.0
[TRACE] 2017-07-11 23:51:17,215 @ qz.printer.action.WebApp:97
    Done: 50.0 > 100.0
[TRACE] 2017-07-11 23:51:17,215 @ qz.printer.action.WebApp:61
    New state: RUNNING > SUCCEEDED
[DEBUG] 2017-07-11 23:51:17,331 @ qz.printer.action.WebApp:161
    Paper area: 0,0:612,792
[DEBUG] 2017-07-11 23:51:17,331 @ qz.printer.action.WebApp:169
    Document will be printed across 2 pages
[INFO] 2017-07-11 23:51:18,200 @ qz.utils.PrintingUtilities:235
    Printing complete
[TRACE] 2017-07-11 23:51:18,200 @ qz.utils.PrintingUtilities:119
    Returning processor back to pool
akberenz commented 7 years ago

Here are the logs after printing using a Render Width and Render Height of 8.27 x 11.69 Before Change [...] foo.html","options":{"pageWidth":"8.27","pageHeight":"11.69"}}]} [...] [TRACE] 2017-07-12 00:05:11,649 @ qz.printer.action.WebApp:244 Setting starting size 793.9199999999998:1122.2399999999998 After Change [...] foo.html","options":{"pageWidth":"","pageHeight":""}}]} [...] [TRACE] 2017-07-12 00:07:28,202 @ qz.printer.action.WebApp:244 Setting starting size 793.3333333333333:0.0 [TRACE] 2017-07-12 00:07:28,224 @ qz.printer.action.WebApp:82 Setting HTML page height to 1940.0

Problem - your second set of logs show you aren't using render sizes

Whenever I change the Render Width and Render Height, the first print job is blank.

Hmm, the logs are exactly the same except for timestamps.. Can you reproduce this with other printer drivers too?

akberenz commented 7 years ago

your second set of logs show you aren't using render sizes

Wait, I'm sorry, that's not what we're testing. We want the page layout to be the same as the System printer settings.

@klabarge, you are configured for "⛔️ CUPS: A4, System: US Letter," right?

This line:

Page layout = Paper=Paper: A4 size=210.0x297.0 MM Orient=PORTRAIT leftMargin=0.0 rightMargin=0.0 topMargin=0.0 bottomMargin=0.0

"Paper" should match your system settings (not CUPS) if it works properly. And don't set any render sizes - the problem comes from where javafx/swing differ in paper size on the defaults.

klabarge commented 7 years ago

Wait, I'm sorry, that's not what we're testing. We want the page layout to be the same as the System printer settings.

Apparently I was also confused on what I was exactly testing.

@klabarge, you are configured for "⛔️ CUPS: A4, System: US Letter," right?

Yes, this is the scenario where the extra "blank pages" are being printed.

"Paper" should match your system settings (not CUPS) if it works properly.

It is still matching CUPS when I change the below line.

- Paper paper = fxPrinter.getPrinterAttributes().getDefaultPaper();
+ Paper paper = fxPrinter.getDefaultPageLayout().getPaper();

"⛔️ CUPS: A4, System: US Letter"

    Message: {"call":"print","promise":{},"params":{"printer":{"name":"PDFwriter"},"options":{"colorType":"color","copies":"1","density":"","duplex":false,"fallbackDensity":null,"interpolation":"","jobName":"","margins":"0","orientation":"","paperThickness":"","printerTray":"","rasterize":false,"rotation":"0","scaleContent":false,"size":null,"units":"in","altPrinting":false,"encoding":"","endOfDoc":"","perSpool":"1"},"data":[{"type":"pixel","format":"html","flavor":"file","data":"file:///Applications/QZ%20Tray.app/demo/multipage.html","options":{"pageWidth":"","pageHeight":""}}]},"timestamp":1499908642368,"uid":"y5lio9"}
[WARN] 2017-07-12 21:17:22,375 @ qz.ws.PrintSocketClient:202
    Bad signature on request
[INFO] 2017-07-12 21:17:23,105 @ qz.common.TrayManager:397
    Allowed localhost to print to PDFwriter
[TRACE] 2017-07-12 21:17:23,105 @ qz.utils.PrintingUtilities:79
    Waiting for processor, 0/3 already in use
[DEBUG] 2017-07-12 21:17:23,106 @ qz.utils.PrintingUtilities:227
    Using qz.printer.action.PrintHTML to print
[DEBUG] 2017-07-12 21:17:23,107 @ qz.printer.PrintServiceMatcher:59
    Searching for PrintService matching PDFwriter
[DEBUG] 2017-07-12 21:17:23,107 @ qz.printer.PrintServiceMatcher:34
    Found 5 printers
[DEBUG] 2017-07-12 21:17:23,118 @ qz.printer.PrintServiceMatcher:110
    Found match: PDFwriter
[DEBUG] 2017-07-12 21:17:23,124 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, zebra, -l]
[DEBUG] 2017-07-12 21:17:23,151 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, zebra_class, -l]
[DEBUG] 2017-07-12 21:17:23,168 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, Print_to_VipRiser, -l]
[DEBUG] 2017-07-12 21:17:23,185 @ qz.utils.ShellUtilities:236
    Parsed default density from CUPS Print_to_VipRiser: 72dpi
[DEBUG] 2017-07-12 21:17:23,185 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, CUPS_PDF, -l]
[DEBUG] 2017-07-12 21:17:23,202 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, PDFwriter, -l]
[DEBUG] 2017-07-12 21:17:23,221 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, Zebra_epl, -l]
[DEBUG] 2017-07-12 21:17:23,240 @ qz.utils.ShellUtilities:236
    Parsed default density from CUPS Zebra_epl: 203dpi
[WARN] 2017-07-12 21:17:23,241 @ qz.printer.PrintOptions:252
    Cannot read null as a double for fallbackDensity, using default
[DEBUG] 2017-07-12 21:17:23,250 @ qz.printer.action.PrintHTML:85
    Parsed 1 html records
[TRACE] 2017-07-12 21:17:23,270 @ qz.printer.action.PrintHTML:190
     Collation = UNCOLLATED
 Copies = 1
 Sides = ONE_SIDED
 JobName = QZ Tray HTML Print
 Page ranges = null
 Print color = COLOR
 Print quality = NORMAL
 Print resolution = Feed res=300dpi. Cross Feed res=300dpi.
 Paper source = Paper source : Automatic
 Page layout = Paper=Paper: A4 size=210.0x297.0 MM Orient=PORTRAIT leftMargin=0.0 rightMargin=0.0 topMargin=0.0 bottomMargin=0.0
[TRACE] 2017-07-12 21:17:23,270 @ qz.printer.action.WebApp:192
    Waiting on print..
[TRACE] 2017-07-12 21:17:23,271 @ qz.printer.action.WebApp:244
    Setting starting size 816.0:0.0
[TRACE] 2017-07-12 21:17:23,271 @ qz.printer.action.WebApp:97
    Done: 100.0 > -1.0
[TRACE] 2017-07-12 21:17:23,271 @ qz.printer.action.WebApp:61
    New state: SUCCEEDED > READY
[TRACE] 2017-07-12 21:17:23,271 @ qz.printer.action.WebApp:97
    Done: -1.0 > 0.0
[TRACE] 2017-07-12 21:17:23,271 @ qz.printer.action.WebApp:61
    New state: READY > SCHEDULED
[TRACE] 2017-07-12 21:17:23,271 @ qz.printer.action.WebApp:61
    New state: SCHEDULED > RUNNING
[TRACE] 2017-07-12 21:17:23,273 @ qz.printer.action.WebApp:97
    Done: 0.0 > 44.881839472003406
[TRACE] 2017-07-12 21:17:23,279 @ qz.printer.action.WebApp:97
    Done: 44.881839472003406 > 50.0
[TRACE] 2017-07-12 21:17:23,295 @ qz.printer.action.WebApp:97
    Done: 50.0 > 100.0
[TRACE] 2017-07-12 21:17:23,295 @ qz.printer.action.WebApp:61
    New state: RUNNING > SUCCEEDED
[TRACE] 2017-07-12 21:17:23,295 @ qz.printer.action.WebApp:82
    Setting HTML page height to 2853.0
[DEBUG] 2017-07-12 21:17:23,409 @ qz.printer.action.WebApp:161
    Paper area: 0,0:595,842
[DEBUG] 2017-07-12 21:17:23,409 @ qz.printer.action.WebApp:169
    Document will be printed across 6 pages
[INFO] 2017-07-12 21:17:24,274 @ qz.utils.PrintingUtilities:235
    Printing complete
[TRACE] 2017-07-12 21:17:24,275 @ qz.utils.PrintingUtilities:119
    Returning processor back to pool

" ✅ CUPS: A4, System: A4"

    Message: {"call":"print","promise":{},"params":{"printer":{"name":"PDFwriter"},"options":{"colorType":"color","copies":"1","density":"","duplex":false,"fallbackDensity":null,"interpolation":"","jobName":"","margins":"0","orientation":"","paperThickness":"","printerTray":"","rasterize":false,"rotation":"0","scaleContent":false,"size":null,"units":"in","altPrinting":false,"encoding":"","endOfDoc":"","perSpool":"1"},"data":[{"type":"pixel","format":"html","flavor":"file","data":"file:///Applications/QZ%20Tray.app/demo/multipage.html","options":{"pageWidth":"","pageHeight":""}}]},"timestamp":1499908792437,"uid":"k4t0bs"}
[WARN] 2017-07-12 21:19:52,440 @ qz.ws.PrintSocketClient:202
    Bad signature on request
[INFO] 2017-07-12 21:19:53,184 @ qz.common.TrayManager:397
    Allowed localhost to print to PDFwriter
[DEBUG] 2017-07-12 21:19:53,300 @ qz.utils.PrintingUtilities:73
    Allowing 3 simultaneous processors based on memory available (1908 MB)
[TRACE] 2017-07-12 21:19:53,301 @ qz.utils.PrintingUtilities:79
    Waiting for processor, 0/3 already in use
[DEBUG] 2017-07-12 21:19:53,316 @ qz.utils.PrintingUtilities:227
    Using qz.printer.action.PrintHTML to print
[DEBUG] 2017-07-12 21:19:53,316 @ qz.printer.PrintServiceMatcher:59
    Searching for PrintService matching PDFwriter
[DEBUG] 2017-07-12 21:19:53,317 @ qz.printer.PrintServiceMatcher:34
    Found 5 printers
[DEBUG] 2017-07-12 21:19:53,327 @ qz.printer.PrintServiceMatcher:110
    Found match: PDFwriter
[DEBUG] 2017-07-12 21:19:53,341 @ qz.utils.ShellUtilities:149
    Executing: [lpstat, -a]
[DEBUG] 2017-07-12 21:19:53,359 @ qz.utils.ShellUtilities:106
    Executing: [lpstat, -l, -p, zebra]
[INFO] 2017-07-12 21:19:53,374 @ qz.utils.ShellUtilities:200
    zebra: zebra
[DEBUG] 2017-07-12 21:19:53,374 @ qz.utils.ShellUtilities:106
    Executing: [lpstat, -l, -p, zebra_class]
[INFO] 2017-07-12 21:19:53,390 @ qz.utils.ShellUtilities:200
    zebra_class: zebra
[DEBUG] 2017-07-12 21:19:53,391 @ qz.utils.ShellUtilities:106
    Executing: [lpstat, -l, -p, Print_to_VipRiser]
[INFO] 2017-07-12 21:19:53,412 @ qz.utils.ShellUtilities:200
    Print_to_VipRiser: Print to VipRiser
[DEBUG] 2017-07-12 21:19:53,413 @ qz.utils.ShellUtilities:106
    Executing: [lpstat, -l, -p, CUPS_PDF]
[INFO] 2017-07-12 21:19:53,429 @ qz.utils.ShellUtilities:200
    CUPS_PDF: CUPS-PDF
[DEBUG] 2017-07-12 21:19:53,430 @ qz.utils.ShellUtilities:106
    Executing: [lpstat, -l, -p, PDFwriter]
[INFO] 2017-07-12 21:19:53,450 @ qz.utils.ShellUtilities:200
    PDFwriter: PDFwriter
[DEBUG] 2017-07-12 21:19:53,451 @ qz.utils.ShellUtilities:106
    Executing: [lpstat, -l, -p, Zebra_epl]
[INFO] 2017-07-12 21:19:53,468 @ qz.utils.ShellUtilities:200
    Zebra_epl: Zebra_epl
[DEBUG] 2017-07-12 21:19:53,469 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, zebra, -l]
[DEBUG] 2017-07-12 21:19:53,503 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, zebra_class, -l]
[DEBUG] 2017-07-12 21:19:53,520 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, Print_to_VipRiser, -l]
[DEBUG] 2017-07-12 21:19:53,538 @ qz.utils.ShellUtilities:236
    Parsed default density from CUPS Print_to_VipRiser: 72dpi
[DEBUG] 2017-07-12 21:19:53,538 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, CUPS_PDF, -l]
[DEBUG] 2017-07-12 21:19:53,555 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, PDFwriter, -l]
[DEBUG] 2017-07-12 21:19:53,573 @ qz.utils.ShellUtilities:106
    Executing: [lpoptions, -p, Zebra_epl, -l]
[DEBUG] 2017-07-12 21:19:53,592 @ qz.utils.ShellUtilities:236
    Parsed default density from CUPS Zebra_epl: 203dpi
[WARN] 2017-07-12 21:19:53,592 @ qz.printer.PrintOptions:252
    Cannot read null as a double for fallbackDensity, using default
[TRACE] 2017-07-12 21:19:53,643 @ qz.printer.action.WebApp:114
    Waiting for JavaFX..
[DEBUG] 2017-07-12 21:19:53,819 @ qz.printer.action.WebApp:125
    Started JavaFX
[DEBUG] 2017-07-12 21:19:54,687 @ qz.printer.action.PrintHTML:85
    Parsed 1 html records
[TRACE] 2017-07-12 21:19:54,873 @ qz.printer.action.PrintHTML:190
     Collation = UNCOLLATED
 Copies = 1
 Sides = ONE_SIDED
 JobName = QZ Tray HTML Print
 Page ranges = null
 Print color = COLOR
 Print quality = NORMAL
 Print resolution = Feed res=300dpi. Cross Feed res=300dpi.
 Paper source = Paper source : Automatic
 Page layout = Paper=Paper: A4 size=210.0x297.0 MM Orient=PORTRAIT leftMargin=0.0 rightMargin=0.0 topMargin=0.0 bottomMargin=0.0
[TRACE] 2017-07-12 21:19:54,874 @ qz.printer.action.WebApp:192
    Waiting on print..
[TRACE] 2017-07-12 21:19:54,875 @ qz.printer.action.WebApp:244
    Setting starting size 793.3333333333333:0.0
[TRACE] 2017-07-12 21:19:54,898 @ qz.printer.action.WebApp:97
    Done: -1.0 > 0.0
[TRACE] 2017-07-12 21:19:54,898 @ qz.printer.action.WebApp:61
    New state: READY > SCHEDULED
[TRACE] 2017-07-12 21:19:54,898 @ qz.printer.action.WebApp:61
    New state: SCHEDULED > RUNNING
[TRACE] 2017-07-12 21:19:54,934 @ qz.printer.action.WebApp:97
    Done: 0.0 > 44.881839472003406
[TRACE] 2017-07-12 21:19:54,947 @ qz.printer.action.WebApp:97
    Done: 44.881839472003406 > 50.0
[TRACE] 2017-07-12 21:19:55,319 @ qz.printer.action.WebApp:97
    Done: 50.0 > 100.0
[TRACE] 2017-07-12 21:19:55,320 @ qz.printer.action.WebApp:61
    New state: RUNNING > SUCCEEDED
[TRACE] 2017-07-12 21:19:55,344 @ qz.printer.action.WebApp:82
    Setting HTML page height to 2853.0
[DEBUG] 2017-07-12 21:19:55,454 @ qz.printer.action.WebApp:161
    Paper area: 0,0:595,842
[DEBUG] 2017-07-12 21:19:55,455 @ qz.printer.action.WebApp:169
    Document will be printed across 3 pages
[TRACE] 2017-07-12 21:19:55,875 @ qz.printer.action.WebApp:192
    Waiting on print..
[INFO] 2017-07-12 21:19:56,876 @ qz.utils.PrintingUtilities:235
    Printing complete
[TRACE] 2017-07-12 21:19:56,877 @ qz.utils.PrintingUtilities:119
    Returning processor back to pool
akberenz commented 7 years ago

So JFX is not what we want to pull this from then. Can you try it with c9c7cf85dd9dc6762a45a3d42b045e2fd71b23d1? This creates a custom paper size from the defaults we gather with Swing.

You should see "Page layout = Paper=Paper: Default size=612.0x792.0 POINT ..." in your logs (or a size matching the System paper settings in 1/72 inches)

klabarge commented 7 years ago

c9c7cf8 seems to do the trick.

I tested various page size combinations, and the page size is always grabbed from System Preferences

tresf commented 6 years ago

c9c7cf8 seems to do the trick.

I tested various page size combinations, and the page size is always grabbed from System Preferences

Closing this as resolved. We can open new bugs reports against 2.1 as defects arise. 👍