Click to See Complete Forum and Search --> : When Evil is Not Evil


chestertb
01-09-2007, 06:45 AM
Ok. I know. You can't bypass the print dialog box from a web page for really god reason. I'm with you.

If you could, the evil ba*&@#! that try to send me ads to make parts of my body bigger or pump up the price of some share they just bought would flood my printer as well as my inbox. I don't want that. Neither does anyone else, and if we allowed it, evil would triumph.

But...

We've written a browser based point of sale system that runs on a localhost server. It sends a receipt to a very cool receipt printer that has windows drivers via the print() function. Up pops the dialog box, which, in a POS system, is mildly inconvenient.

I've been reading a little about ActiveX, and I understand that it's theoretically possible to write an ActiveX control to bypass the print dialog.

If we can't do the ActiveX thing, my next guess would be to seed the receipt data into a java applet on the server and print it from there, but java isn't something we've dabbled with.

Anyone know an ActiveX control that will do what we're looking for, or have any other thoughts?

CTB

Watts
01-09-2007, 03:41 PM
Dymo Label Printers has something similar utilizing ActiveX and JavaScript. Poke around on their website for more details.

chestertb
01-10-2007, 07:08 PM
Thanks Watts. I'll give them a call.
Cheers
CTB

Stephen Philbin
01-10-2007, 10:23 PM
Didn't service pack 2 for Windows XP disable ActiveX or something like that? You might want to make sure ActiveX is still working on your recieving computer and that it hasn't been silently disabled by some update or just switched off for some reason by a member of staff.

Watts
01-11-2007, 11:33 AM
Here is the chunk of code I use: Its JavaScript that I believe calls the ActiveX Object (?) - I basically use onLoad to call the function so when my webpage loads the label is printed using data passed along in a form.


function PrintBtnClicked() {

var DymoAddIn, DymoLabel;
DymoAddIn = new ActiveXObject('DYMO.DymoAddIn');
DymoLabel = new ActiveXObject('DYMO.DymoLabels');

// change location of label file directory and field names below
// field names will match label fields where SetAddress == Address field type and SetText == Text field type

if (DymoAddIn.Open('F:\\Admin\\Dymo\\NewFile.LWL')) {
DymoLabel.SetAddress(1, dymoLabel.Name.value);
DymoLabel.SetAddress(2, dymoLabel.Number.value);
DymoLabel.SetAddress(3, dymoLabel.Date.value);
DymoAddIn.Print(1, true);
}

else
alert('Error: Label file Not Found!');
}


It's one of those things I didn't expect to actually work, so when it did I didn't spend any time jacking with it and just considered myself lucky. It's part of their development kit and you have several options to choose from (and you have to choose between IE and FF).