By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,728 Members | 1,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,728 IT Pros & Developers. It's quick & easy.

Printing a text file from a web application?

P: n/a
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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]
"Benny" <an*******@devdex.com> wrote in message news:eX**************@TK2MSFTNGP12.phx.gbl...
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #2

P: n/a
Thanks for the reply. My sitution is print from the server. I got the
solved from your suggestions. Thanks.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.