How Do I send buffer to Printer ?

J

Jay Villa

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTemplateFile = objFSO.OpenTextFile(Server.MapPath("template.txt"))

strTemplateText = objTemplateFile.ReadAll
objTemplateFile.Close
Set objTemplateFile = Nothing

strTextToPrint = strTemplateText
strTextToPrint = Replace(strTextToPrint, "{date}", Date())
strTextToPrint = Replace(strTextToPrint, "{time}", Time())
strTextToPrint = Replace(strTextToPrint, "{message}", strMessage)
Response.Write strtexttoprint

How do I send strTextToPrint to my default printer ?

-Jay
 
M

[MSFT]

Hello Jay,

Since the strTextToPrint has been send to client browser, I think you can
call "window.print" on client to print current page on default printer.

Luke
 
J

Jay Villa

Actually I dont want to print entire page only the the contents of
strTextToPrint. window.print.
 
M

[MSFT]

Hello Jay,

With client script, we can only print the content of whole page. Anyway, I
think there may be a work aound for the issue: add a iFrame element on your
page (Maybe invisible if necessary). After a fill in data and select the
template, you may display the result page in the iFrame element and call
window.print in it.

Luke
 
J

Jay Villa

Thanks Luke for your suggestion. Actually I used print window/area as shown
below and it worked as I wanted.

var printWin = window.open("","PrintWindow");
printWin.document.open();
printWin.document.write(sContents);
printWin.document.close();
printWin.print();
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top