Print Page | Close Window

Server Side Printing?

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=28859
Printed Date: 28 March 2026 at 3:11pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Server Side Printing?
Posted By: kennywhite
Subject: Server Side Printing?
Date Posted: 17 September 2010 at 7:04pm
Hello,

I have a page that I need to be able to print on the web server. This is a network printer, that I would like to be able to print to via IP address. If need be, I can set it up on an LPT port.

I've found a few examples online, but I haven't had any luck with those. 

Anyone able to help?

Thanks a bunch!



Replies:
Posted By: kennywhite
Date Posted: 20 September 2010 at 8:22pm
I found this article and tried this out. 

http://www.asp101.com/articles/john/serversideprint/network.asp" rel="nofollow - http://www.asp101.com/articles/john/serversideprint/network.asp

When entering the proper credentials I get this error message:

Error Type:
WSHNetwork.AddPrinterConnection (0x80070005)
Access is denied.

Does anyone else have better results?

Is there another method of doing this? 


Posted By: dpyers
Date Posted: 20 September 2010 at 9:45pm
IUSER_ASP needs permissions for the printer.

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: kennywhite
Date Posted: 22 September 2010 at 5:34pm
I have done that and I am able to print the text in the message box. 

With this method will it be possible to print a pre-formatted webpage or is this limited to text only? If I can, is there any advice on how I can go about it?

Thanks.




Posted By: dpyers
Date Posted: 22 September 2010 at 9:55pm
Depends what you mean by pre-formatted.

You can use the common VB escape sequences like carriage return, line feeds, tabs, etc within the string you send to the printer. You can also encode the specific printer escape sequences to send machine level commands to the printer which uses some version of PCL (Printer Control Language).

Web pages are actually printed by the browser which takes the html it receives and converts it to PCL to retain the html formatting. That conversion is not something you'd want to script within an asp page.

EDIT: Be aware that you have no way to interface with messages from the printer which is why people seldom use server-side printing. It's possible for an out-of-paper, offline or some other error message that you have to respond to (e.g. click OK) to hang the printer and/or the server.




-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: kennywhite
Date Posted: 23 September 2010 at 2:40pm
The page that would need to be printed would contain bar code fonts, a table with a list of part numbers, names, locations, and so on. All of this data will be pulled from an Access database. Do you think this is possible?

The document would always go to the same printer and the person in charge wants the user to be blind to the printing. Also, the primary user interface will be accessed on a PDA that does not have printing capabilities. 

Should I look to another language to do this? Do you have any suggestions?

Thanks so much for your input.


Posted By: dpyers
Date Posted: 23 September 2010 at 5:45pm
Web servers just return raw data (usually text). When the server is returning data to the browser, part of that data includes formatting instructions for the browser (html).

When returning data to a printer, that html would need to be replaced with formatting instructions the printer can recognize (PCL, XPS, or Postscript). PCL instructions are binary and require escape sequences. Postscript instructions are text (like html - but for printers instead of browsers) and require a postscript compatible printer.
XPS is XML Paper Specification and can be used to send the data+Format to either the Printer or the spooler on Vista and Win7 systems. Some printers support XPS directly but they're few and far between.

Other than sending data directly to the printer, you can send data to the windows spooler or to the printer driver (maybe) but it is a bit more complicated.


Ultimately, it sounds like you have a workflow issue. If I understand the situation correctly, you want to store info and print a piece of paper when the user submits the form. The paper is printed somewhere the user isn't for the system administrator to use.

I'd question the need to print the paper in real time. The cost/benefit just isn't good. I would either use MS Access, Excel, or an asp based browser script to suck data off the DB and return it all formatted for printing. The admin could do that whenever they're ready to handle the paper or you could use windows scheduler/script to do it automagically.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: kennywhite
Date Posted: 23 September 2010 at 9:15pm
Yes, that pretty much is the situation. I'm going to try to talk them into just having Crystal Reports run every hour and print out the information, I think that application uses too many resources to run more frequently than that.

If need be, I'll try to implement another solution at some other point, but hopefully that will do for now.

Thanks a lot for your help, dpyers! 



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net