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

qz-print 1.9.7 setRotation #193

Closed klabarge closed 7 years ago

klabarge commented 7 years ago

Tested using the applet version 1.9.7

When using setRotation a NullPointerException is thrown.

Code snippet

function printPDF() {
    if (notReady()) { return; }
    qz.setPaperSize("6.0in", "4.0in");
    qz.setRotation("90");
    qz.appendPDF(getPath() + "assets/pdf_sample.pdf");
    // Automatically gets called when "qz.appendPDF()" is finished.
    window['qzDoneAppending'] = function() {
        // Tell the applet to print PostScript.
        qz.printPS();

        // Remove reference to this function
        window['qzDoneAppending'] = null;
    };
}

Stacktrace

Nov 10, 2016 8:32:55 PM qz.PrintApplet call
INFO: Successfully called JavaScript function "qzDoneFinding(...)"...
Nov 10, 2016 8:32:55 PM qz.PrintApplet notifyBrowser
INFO: Successfully called JavaScript function "qzDoneFinding(...)"...
Nov 10, 2016 8:32:58 PM qz.PrintFunction setPaperSize
INFO: Set paper size to 6.0inx4.0in
Nov 10, 2016 8:32:58 PM qz.PrintApplet call
INFO: Successfully called JavaScript function "qzDoneAppending(...)"...
Nov 10, 2016 8:32:58 PM qz.PrintApplet notifyBrowser
INFO: Successfully called JavaScript function "qzDoneAppending(...)"...
Nov 10, 2016 8:32:58 PM qz.PrintFunction logCommands
INFO: 

    <<http://localhost/qz-print-1.9/demo/assets/pdf_sample.pdf>>

Nov 10, 2016 8:32:58 PM qz.common.LogIt log
INFO: Rotating image 1.5707963267948966
Nov 10, 2016 8:32:58 PM qz.common.LogIt log
SEVERE: Error
java.lang.NullPointerException
    at qz.PrintPostScript.rotate(Unknown Source)
    at qz.PrintPostScript.print(Unknown Source)
    at qz.PrintFunction.logAndPrint(Unknown Source)
    at qz.PrintFunction.printPS(Unknown Source)
    at qz.PrintApplet.startJavaScriptListener(Unknown Source)
    at qz.PrintApplet.access$000(Unknown Source)
    at qz.PrintApplet$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at qz.PrintApplet.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

java.lang.NullPointerException
    at qz.PrintPostScript.rotate(Unknown Source)
    at qz.PrintPostScript.print(Unknown Source)
    at qz.PrintFunction.logAndPrint(Unknown Source)
    at qz.PrintFunction.printPS(Unknown Source)
    at qz.PrintApplet.startJavaScriptListener(Unknown Source)
    at qz.PrintApplet.access$000(Unknown Source)
    at qz.PrintApplet$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at qz.PrintApplet.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Nov 10, 2016 8:32:58 PM qz.PrintRaw clear
INFO: Print buffer has been cleared.
Nov 10, 2016 8:32:58 PM qz.PrintApplet call
INFO: Successfully called JavaScript function "qzDonePrinting(...)"...
Nov 10, 2016 8:32:58 PM qz.PrintApplet notifyBrowser
INFO: Successfully called JavaScript function "qzDonePrinting(...)"...
tresf commented 7 years ago

Confirmed however PDFRenderer doesn't offer an easy way to honor PDF rotation, so we'll have to close this as wontfix.

The recommended workaround is to use landscape via:

qz.setPaperSize("4in", "6in")
qz.setOrientation("landscape");

image

tresf commented 7 years ago

Closing as wontfix. Please use landscape orientation instead.