Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing rawdata through VBscript in clients browser

Status
Not open for further replies.

stefantastisk

Programmer
Feb 24, 2003
2
0
0
DK
Hey people
I am stuck with the situation that I want to print rawdata through the clients browser, without ANY formatting at all, because the formatting is included in some syntax that only the printer is familar with.
Actually I want to simulate the dos command "print" through the browser and to the clients printer.
Being an inexperienced VB programmer but a fairly good VBscripter, I've found the VB method "Open", for instance:
Open "LPT1" For Output As f
Print #f, "String"
Close #f
Is it possible in some way to do this through VBscript ?

Hope you guys are capable of giving me a good answer :)

I'm out
/S
 
stefantastisk

Question. You say you wish to print through the users browser.

However, will EVERY user that accesses your page and then trigger your printing have LPT1 or a locally attached printer?

If not, why not use FSO to read the data from the file and create HTML/ASP page with <PRE> formatted text and then let the user decide which printer they want to direct it to? This will retain the look and feel of the original and allow the flexibility as to where it needs to print.

Again, you may be positive that all your users will have an LPT1 printer, and if that is the case your proposed approach may be the most expedient. However, what if their printer is down, or out for repair or out of toner? Then your users would be getting an error.

Just a few thoughts.
DougCranston
 
Hey DougCranston

You are right, I cannot use the LPT1 because my users are connected to a printserver. I didnt tell you guys that fact, my fault !!.

I've suggested the preformatting solution to the customer. But the invoices we are expected to print should have a VERY specific look, and formatting with html and css, do have different looks on different printers, so their &quot;postscript&quot; alike solution seems to be the only way :(

This IS a tough task :).

But tnx for your thoughts DougCranston
Stefantastisk
 
Sorry to be a wet blanket.

Ran into a similar situation for my intranet, and had a developer create an app that created PDF documents on an as need basis. Ex. Internal Directory, with frequent changes this was the only solution they would accept.

If your stuck with precise formatting, with the output expected to look the same no matter what system you receive and print to, PDF appears to be the only solution.

Have done some research recently on this, and if you search you can find a range of solutions.. Ones where you write a C(+ or ++ or # or .NET) app that includes a vendors library. Or some composite of GNU and commercial products (Adobe Acrobat) to automate the doc's creation. Success on the later would be clients willingness to use the combination of GNU Ghostwriter to create Postscript and Adobe Distiller to turn it into a PDF.

Good luck.
DougCranston
 
Here's some code similar to the VB &quot;Open/Print/Close&quot; method but in VBScript. As you can see, it accepts a UNC to the print server's share. It prints unformatted text just like a DOS PRINT. I've used the concept to print mailing labels from an HTML Application (HTA) that accesses an ODBC datasource. This is just an quick test script but shows how it works. Of course you'll have to change &quot;\\PRINTSERVER\PRINTER&quot; to something in your environment. Also, that could be &quot;LPT1:&quot; or other LPT port.

Set FSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objPrinter = FSO.CreateTextFile(&quot;\\PRINTSERVER\PRINTER&quot;, True)
objPrinter.WriteBlankLines 1
objPrinter.WriteLine(&quot;This&quot;)
objPrinter.WriteLine(&quot;is a&quot;)
objPrinter.WriteLine(&quot;Test&quot;)
objPrinter.WriteBlankLines 3
objPrinter.WriteLine(&quot;This&quot;)
objPrinter.WriteLine(&quot;is a&quot;)
objPrinter.WriteLine(&quot;Test&quot;)
objPrinter.Close
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top