Groups | Blog | Home
all groups > c# > january 2004 >

c# : Printing a text file from a web application?


Benny
1/28/2004 11:20:00 PM
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 ***
Sorin Dolha [MCSD]
1/29/2004 10:20:50 AM
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,

--=20
Sorin Dolha [MCP, MCAD, MCSD]
[quoted text, click to view]
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 ***
Benny
1/29/2004 6:42:38 PM
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 ***
AddThis Social Bookmark Button