Printing | How the network uses ASP for print operations
Technology to use:
Asp,wsh,vbscript
The file aspprint.asp code is as follows:
<%@ Language=vbscript%>
<%
Option Explicit
The value in the Dim strsubmit ' form to hold the Submit button
Value of saving network printer path in Dim strprinterpath ' form
Value of user name in Dim strusername ' form
The value of the password in Dim strpassword ' form
Dim strmessage ' form prints the value of the content
File system objects in Dim OBJFS ' VBScript
Network objects in Dim objwshnet ' WSH
Dim objprinter ' Print object
Strsubmit = Request.Form ("Submit")
%>
<HTML>
<HEAD>
<meta name= "generator" content= "Microsoft Visual Studio 6.0" >
</HEAD>
<BODY>
<%
If strsubmit = "" Then
%>
Note that:
Because I am a demo, where the account and password for NT are used unencrypted means to pass in the ASP
The login process should be handled securely in the real application.
<form action= "aspprint.asp" Method=post id=form name=form>
<table width=100% align=center border=0 cellspacing=1 cellpadding=1>
<TR>
<TD align=right nowrap> Network printer path:</td>
<TD align=left nowrap><input type= "text" Id=printerpath Name=printerpath
Value= "\\< Domain >\< Printer >" ></TD>
</TR>
<TR>
<TD align=right nowrap> Login account:</td>
<TD align=left nowrap><input type= "text" Id=username Name=username
value= "<% = strUserName%>" ></TD>
</TR>
<TR>
<TD align=right nowrap> Login Password:</td>
<TD align=left nowrap><input type= "password" Id=password
Name=password></td>
</TR>
<TR>
<TD align=right nowrap> Please enter the text you want to print:</td>
<TD align=left nowrap><textarea rows=2 cols=20 id=message
Name=message></textarea></td>
</TR>
<TR>
<TD align=right nowrap> </TD>
<TD align=left nowrap><input type= "Submit" value= "Submit"
Id=submit name=submit></td>
</TR>
</TABLE>
</FORM>
Once the above information has been submitted, it can be printed with the following code.
<%
Else
' Get the response information from the form.
Strprinterpath = Request.Form ("PrinterPath")