How to print from the web server?

N

Nikolay Seksenov

I am developing VB.Net Web application to be used in our
department intranet. I created a web-based report using
Crystal Reports. I would like to print the report from the
web server instead of printing from the browser because
the latest will add additional text to the pages and it
also requires printing each page separately. In order to
do this I followed the steps described in
article "Printing Web-Based Reports from the Server",
which suggested to change the <ProcessModel> tag in
machine.config file (userName="SYSTEM" instead of
userName="machine") and also completed the steps described
in related articles Q152451 and Q184291: I added a local
printer on server's LPT1 port and then attached the
network printer to lpt1 using "net use lpt1:
\\server\printer" command. Then I made this printer
default printer and printed test page ok. Also I copied
registry settings from HKEY_CURRENT_USER to
HKEY_USERS\.DEFAULT as described in articles above.

During the report page Page_Load event the following code
is executed:
Dim MyRpt As New Crystal1
Dim MyPrinter As New System.Drawing.Printing.PrintDocument
Dim strPrinterName As String
....
strPrinterName = MyPrinter.PrinterSettings.PrinterName()
'Checked the variable above in debug mode: contains
correct printer name
MyRpt.PrintOptions.PrinterName = strPrinterName
MyRpt.PrintToPrinter(1, False, 0, 0)

When executing the last command got the error message with
heading: "Printers Folder" and text: "There was an error
found when printing the document "..." to LPT1:. Do you
want to retry or cancel the job" with Retry and Cancel
buttons.
Before clicking on any of those buttons I opened the
virtual Printers directory of the web server and found
the document in the Document List queue with the status
of "Error - Printing". After clicking on Cancel the
document disappears from the Document List.

Can somebody help?
 
A

AlexB

It sounds like you're on the right track. Essentially, to
print from the server you have the have the printer you
want to access configured for the user account that
ASP/Crystal uses - according to the KB articles you
referred to. It sounds like you just need a bit more
test/troubleshooting. I had to pull my hair out over it a
bit, also, but it finally worked just fine for all of the
printers configured on the server.

Hope that helped some.
 
N

Nikolay Seksenov

Thank you Alex,

The account which is used by ASP is ASPNET and it is local
account. Do you have any suggestions how to configure this
account in order to access network resourses?

Nick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top