Printing a text file from a web application?

B

Benny

Hello Experts,

Currently I working on a web application using vs.net with C#.

I require to create an invoice to a text file and print the file. I have
no problem with writing to the text, but how can I print a text file
using C# in a web application? Any articles that shows you how can this
be done will be great.


Thanks in advanced,

Benny
 
S

Sorin Dolha [MCSD]

Benny,

Because a Web Application is a client-server layered application, there are two situations:
a.. You want to print to a printer on the server. (1)
b.. You want to print to a printer on the client computer. (2)
In the first situation, you can print just as you would have printed in a Windows Forms (see this for some samples and detailed information about printing from C#), just take care that the user identity which ASP ..NET is running with has been granted Print permissions on the requested printer (if you didn't use impersonation, ASP .NET is running as the [DOMAIN]\ASPNET user of your domain if you are running Windows 2000 or Windows XP, or NTAUTHORITY\NETWORK SERVICE user if you are running Windows Server 2003).

For the second situation, it will not be that easy.
You might want to create an ActiveX or another type of component (for example, a Windows Forms application which will be downloadable from a web form of your Web Application, after a security will warn the user that he or she is downloading code which will run on his or her computer) which could do the printing job on the client computer (because of security reasons). To obtain data to print, your client component can access the web server through an XML Web Service which you should also implement on the Web server (for example, in the same Web Application where the Web form resides).

Or, if you don't have too complex reports to print, you may simply generate a "print-ready" HTML from your ASP .NET Web Form, so that the user will only have to click on the Print toolbar button of Internet Explorer (or his or her browser) to print the information. Many sites offer two versions of their Web Forms: for reading on the screen and for printing. Users can switch between them at any time through simple hyperlinks.
I hope it helped,

--
Sorin Dolha [MCP, MCAD, MCSD]
Hello Experts,

Currently I working on a web application using vs.net with C#.

I require to create an invoice to a text file and print the file. I have
no problem with writing to the text, but how can I print a text file
using C# in a web application? Any articles that shows you how can this
be done will be great.


Thanks in advanced,

Benny
 
B

Benny

Thanks for the reply. My sitution is print from the server. I got the
solved from your suggestions. Thanks.
 

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