Issues sending raw print to printer on save.

Hi there.

I have a problem with a closed question:

I need a few more details to make it Work. :-)  This is what I can do so far:

Installing the printer and driver. I can also make prints to the printer from the QZ Print on:

But then I get a Little lost about what code to place where:

function print()   - where should that be located?

and the code snippet after that should be where?

I do understand that asp will be processed before java.

I would appreciate BIG time if you could give me a few more hints. I'm not a super nerd into java and AJAX. Classic asp I do know well.

Thank you in advance.

Best regards

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I am tied up right not for too much detail.  But have a look at their test page

View the source and think of each button as it's own module which you have already tested.   Your next step is to take just one portion of it an make it work using only html.

Let's look at the Print EPL button. It has an onClick call to printEPL().  Just look for that in the code by viewing the source.

Looks like this is it.
 * Prototype function for printing raw EPL commands
 * Usage:
 *    qz.append('\nN\nA50,50,0,5,1,1,N,"Hello World!"\n');
 *    qz.print();
function printEPL() {
    if (notReady()) { return; }

    // Send characters/raw commands to qz using "append"
    // This example is for EPL.  Please adapt to your printer language
    // Hint:  Carriage Return = \r, New Line = \n, Escape Double Quotes= \"
    qz.append('A310,26,0,3,1,1,N,"SKU 00000 MFG 0000"\n');
    qz.append('A310,56,0,3,1,1,N,"QZ PRINT APPLET"\n');
    qz.append('A310,86,0,3,1,1,N,"TEST PRINT SUCCESSFUL"\n');
    qz.append('A310,116,0,3,1,1,N,"FROM SAMPLE.HTML"\n');
    qz.appendImage(getPath() + 'assets/img/image_sample_bw.png', 'EPL', 150, 300);

    // Automatically gets called when "qz.appendImage()" is finished.
    window['qzDoneAppending'] = function() {
        // Append the rest of our commands

        // Tell the applet to print.

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

Open in new window

Get that to work.  Delete all the other code except what you need like the functions for qz.print(); and qz.append etc. and now get this to work only using html/js  (by the way, it is javascript, not java, two different things)

Next to last step is get this to work using asp.  This is the long part because you will need to response.write all of this out.  Remember that asp and vbscript run on on the server.  HTML, CSS and Javascript render in the browser from data sent by the server. Therefor, your asp code can generate your html and javscript, but not the other way around.

You are going to have to go through each line and covert it to one long string then output the string.

I  won't do it all but assume the entire code is made up of these two lines of javascript.

Open in new window

myJS = "<script>"
myJs = myJs &"qz.append('\nN\n');"
myJs = myJs &"qz.append('q609\n');"
myJs = myJs &"</script>"

response.write myJs

Open in new window

Above code will send js code to the browser just as if you hand typed it.
var1 = "q609"
myJS = "<script>"
myJs = myJs &"qz.append('\nN\n');"
myJs = myJs &"qz.append('"&var1&"');"
myJs = myJs &"</script>"

response.write myJs

Open in new window

Above will print out the same thing but we used a variable.  

Your best bet is to start with what works and keep building like I have here until you get it working fully on the fly.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Note: I edited the last line of the code.

myJs = "</script>"
should be
myJs = myJs &"</script>"
ullenulleAuthor Commented:
Hi Scott.

Thank you. You are a hero! :-)  I know Java isn't Javascript. Anyways... I have one problem right now: Where do I find qz.print(); and qz.append? I can't find them in the source. Or am I looking at the wrong spot?

Best regards

The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Those are functions that I think just talk to the applet. As long as you have the supporting files you are good.
ullenulleAuthor Commented:
Ok. I feel so dumb with Javascript... The "sample.html" Works fine locally from my computer, but if I upload it to the webserver including the:

<script type="text/javascript" src="js/3rdparty/deployJava.js"></script>
<script type="text/javascript" src="js/qz-websocket.js"></script>

... and adding ../  to the source like:

<script type="text/javascript" src="../js/3rdparty/deployJava.js"></script>
<script type="text/javascript" src="../js/qz-websocket.js"></script>

so that it's relative to the sample-html, then it won't Work. I just want to make it Work on the server step by step... dooohhh.... :-(
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Can you post a link to your test page?
ullenulleAuthor Commented:
Unfortunately  not. It's an internal server at work behind firewalls and stuff, so there's  only access for employees in a specific department.
ullenulleAuthor Commented:
Top notch! ;-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.