Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Printing and ASP
Message
From
20/06/2001 22:52:46
 
 
To
20/06/2001 14:50:34
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00521615
Message ID:
00521744
Views:
20
>I would like to know how can I print a text file located on my server from an ASP page...Thx!

You cannot automatically print to the client. However, you can display the file as plain text on the browser, for the user to print using the browser's "Print" command.
For example:
set fso = createobject("scripting.filesystemobject")
Set f = fso.OpenTextFile("c:\myfile.txt")
Response.ContentType = "text/plain"
Response.Write f.ReadAll
Set f = nothing
Set fso = nothing
Response.End
You can use Server.MapPath to get the physical directory where the file is located, if you don't know it:
myfile = Server.MapPath("myfile.txt")
'then use
Set f = fso.OpenTextFile(myfile)
or, you can simply re-direct the user to your text file, and the browser will open it as text, after which the user can print it:
response.redirect "c:\myfile.txt"
Hope this helps.
Andres M. Chiriboga, MCSE, MCP+I
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform