Printing from ASP

Posted on 2002-07-23
Last Modified: 2012-06-27
How can I print a text file from ASP?
Question by:insight974
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7172835
Please maintain your open questions:
Help Desk System Date: 03/07/2002 07:00AM PST
Granulated security Date: 06/13/2002 11:40AM PST
URL Date: 06/27/2002 06:57PM PST
(the above question shold be deleted as there are no contributions)
Authentication without asking for user name and password Date: 04/05/2002 06:44AM PST


Expert Comment

ID: 7172877
Anthony's correct, the answer to your question isn't to complicated...but why answer it if i don't think i'll get the points anyway??

 ~ MastaLlama ~

Expert Comment

ID: 7173466
<a href="javascript:window.print();">Print</a>
LVL 19

Expert Comment

ID: 7173744
zombeen is right, that's the easiest won't always work but it's close enough. There's no way in ASP to execute special print commando's so don't go hoping for that, just accept zombeen's comment and off you go...


Author Comment

ID: 7174109
Thank you for the answers. I'm sorry about the delay in the responses. I was making a mistake when giving the points, I was thinking I was closing the questions and that wasn't happening. I'm really very sorry. And in one case, I haven't received any response. Thanks to acperkins for letting me know, I really feel bad about it. I have just reviewed the previous questions and closed them. Sorry.

Related to this question, what I need is to print a text file that was saved in the hard drive. Thank you
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

LVL 18

Expert Comment

ID: 7174806
Use the FSO to open the file as a formated string, then pass that to the print() function.

But if this .txt file is on the users hard-drive, you will have problems... the only other way around it is to upload the .txt to the server, then run it through the print() and then delete the file.

Author Comment

ID: 7174989
Let me explain more. I have a variable with a string in the asp page, what I will need is to print that string (to the default printer). As I don't have an idea on how to do it I was thinking on creating a temp txt file and send the file to print but I'm open to other ideas.
LVL 18

Accepted Solution

mgfranz earned 100 total points
ID: 7176137
Like I said, write the string to a temp file with the FSO, then call print() from the file;

Sub CreateAfile
   Dim fso, MyFile
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set MyFile = fso.CreateTextFile("c:\testfile.txt", True)
   MyFile.WriteLine("This is a test.")
End Sub

' Now redirect to the print.asp file
' it would be better to open a new window to do this
Response.Redirect "print.asp"


<!--#include file ="c:\testfile.txt"-->
<script language="javascript">

function printPage()
     // Now close the window
<body onLoad="javascript:printPage();">

LVL 33

Expert Comment

ID: 7348972
This question appears to have been abandoned. I will invite a Moderator to close this question if there's no reply from you after seven days.

<points to mgfranz>


Expert Comment

ID: 7373630
Per recommendation, force-accepted.

CS Moderator

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now