Re: qz print for php web apps

38 views
Skip to first unread message

Tres Finocchiaro

unread,
Mar 11, 2021, 1:06:19 AM3/11/21
to Sharmily G, qz-print
This question seems to have been posted twice.  I've begun answering it here: https://groups.google.com/g/qz-print/c/Dh_J8GpEqdQ/m/jCAUsY8kAgAJ


On Thu, Mar 11, 2021 at 12:14 AM Sharmily G <sharm...@ontabee.com> wrote:
Hi Guys tried the below code for checking qz runing but i face a issue : Error unable to establish connection with qz tray .

<html><head><meta charset="UTF-8"></head> <body> <!-- USAGE: index.php?var1=some_value_to_print --> <?php if (isset($_GET["var1"])) { echo '<!-- FROM PHP --><script>var var1 = "' . htmlspecialchars($_GET["var1"]) . '";</script>'; } else {?> <form action="index.php" method="get">Some value: <input type="text" name="var1"><br> <input type="submit" value="Print"></form></body></html> <?php die(); } ?> <!-- FOR QZ TRAY --> <script type="text/javascript" src="https://rawgit.com/qzind/tray/2.0/js/dependencies/rsvp-3.1.0.min.js"></script> <script type="text/javascript" src="https://rawgit.com/qzind/tray/2.0/js/dependencies/sha-256.min.js"></script> <script type="text/javascript" src="https://rawgit.com/qzind/tray/2.0/js/qz-tray.js"></script> <script> var printer = "Epson"; qz.websocket.connect().then(function() { return qz.printers.find(printer); }).then(function(found) { var config = qz.configs.create(found); var data = "\n\n\n\n\n\n\n\n\n\n" + var1 +// echoed above via php "\n\n\n\n\n\n\n\n\n\n"; return qz.print(config, [data]); }).then(qz.websocket.disconnect).then(function() { document.getElementById('status').innerHTML = 'Done'; }).catch(function(err) { document.getElementById('status').innerHTML = err + '<br><a href="qz:launch">Launch QZ</a>'; throw err; }); </script> <h1 id="status">Attempting to print...</h1> </body> </html>

Please help me in solving the issue

--
You received this message because you are subscribed to the Google Groups "qz-print" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qz-print/43b934f8-7478-41f5-a066-4ef9002cc6e7n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages