Question

I have created a simple asp.net application that takes input from a user on a production line and then it needs to generate 5 barcodes and print them. I have the vbhtml pages that generate bar codes automatically when data is entered and inserted via the web page form. They open and display the barcodes. I need them to print automatically when the page opens by skipping the print dialog and going straight to the default printer.

I have studied the JS window.print() and a couple JQuery Plugins, but I cant quite get my solution.

This will only be used on an internal corp network

Here is more info: The barcodes will open in a web page for each code. Each barcode will print to a different size label. The label size is saved as a named layout in the printer and I would like to define a paper layout when I print.

Was it helpful?

Solution

If you are/can use Firefox there is a plug in which allows unattended printing without print dialog.

I have also read that you can do it in IE, but requires ActiveX, for example:

<script language=JScript>
function doprint() {
document.body.insertAdjacentHTML("beforeEnd", "<object id='idWBPrint' width=0 height=0 classid='clsid:8856F961-340A-11D0-A96B-00C04FD705A2'></object>");
idWBPrint.ExecWB(6, -1);
idWBPrint.outerHTML = ""; }
</script>

Or similar in VBScript:

<script language='VBScript'>
Sub Print()
       OLECMDID_PRINT = 6
       OLECMDEXECOPT_DONTPROMPTUSER = 2
       OLECMDEXECOPT_PROMPTUSER = 1
       call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER,1)
End Sub
document.write "<object ID='WB' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>"
</script>

That Sub Print effectively replaces the default print function. All you then need in Javascript is...

window.print();

There's also a commercial product that may help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top