borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Printing On Labels)Next Topic (How do I programatically modify printer settings from VB?) New Topic New Poll Post Reply
AndreaVB Forum : Printing : Dos based printing
Poster Message
rana
Level: Guest


icon Dos based printing

Hi i want to know how print dos based i.e. fast printing using vb

07-12-2002 at 04:25 AM
| Quote Reply
Chris_871
Level: Master


Registered: 30-11-2002
Posts: 106
icon Re: Dos based printing

I too had the same problem. But I have solved with the following method.

For example, If you want to print a invoice you have to convert the invoice into text format.To do that you can use the file system object.

from project reference select Microsoft scripting runtime.

from the general declaration write the following code.
Dim fso As New FileSystemObject
Dim ts As TextStream


write the following code into any buttonclick event.

Set ts = fso.CreateTextFile(App.Path & "invoice.txt")
      
      ts.Write Space(0) & Chr(15) & "Bill No  : " & rs(0) & Space(11) & billstat & Space(12) & "Phone : " & rs(6) & vbCrLf & vbCrLf
      ts.Write Space(25) & rs(4) & vbCrLf   'Company Name
      ts.Write Space(15) & rs(5) & vbCrLf & vbCrLf 'Address

ts.write vbcrlf


....
....
....

Note : In this example i have used the recordset values.(rs(0),rs(1) etc.

Now the text file is ready.

If you print the text file directly from VB you won't get fast. So you have to print the text file from DOS prompt.

Write a printing command in a BAT file and run it from VB.

To do that

make a bat file called invprint.bat and write the following command.

type invoice.txt > prn

then save the file.


If you run the batch file from VB you will get the fast printing.

write the following code into the buttonclick event

dim fp as string
fp = Shell("invprint.bat", vbHide)


Best wishes
  

[Edited by Chris_871 on 14-01-2003 at 09:32 AM GMT]

06-01-2003 at 05:05 AM
View Profile Send Email to User Show All Posts | Quote Reply
ReaperAlex
Level: Guest

icon Re: Dos based printing

Hi, I'm doing just this but I have an extra twist.  How do I get a networked PC to print in fast mode?  I can't figure how to send the data to another machines lpt port.  Any ideas?

Thanks, ReapeR

13-01-2003 at 02:17 PM
| Quote Reply
saj
Level: Guest

icon Re: Dos based printing

quote:
ReaperAlex wrote:
Hi, I'm doing just this but I have an extra twist.  How do I get a networked PC to print in fast mode?  I can't figure how to send the data to another machines lpt port.  Any ideas?

Thanks, ReapeR

09-03-2003 at 05:54 PM
| Quote Reply
saj
Level: Guest

icon Re: Dos based printing

When printing dos based text through vb via calling shell
vbhide is used to suppress the dos screen.  But when you have contnueous printing.  the vbhide stays at the background which reduces the system memory and at later stage the system cannot access the batch file and the print stops.  You have to then reboot the system to continue the printing jon.
Anybody knows how to clear the vbhide.

Regards


[Edited by saj on 09-03-2003 at 06:02 PM GMT]

09-03-2003 at 05:58 PM
| Quote Reply
saj
Level: Guest

icon Re: Dos based printing

When printing dos based text through vb via calling shell
vbhide is used to suppress the dos screen.  But when you have contnueous printing.  the vbhide stays at the background which reduces the system memory and at later stage the system cannot access the batch file and the print stops.  You have to then reboot the system to continue the printing job.
Anybody knows how to clear the vbhide from the memory.

Regards

09-03-2003 at 06:00 PM
| Quote Reply
saj
Level: Guest

icon Re: Dos based printing

quote:
Chris_871 wrote:
I too had the same problem. But I have solved with the following method.

For example, If you want to print a invoice you have to convert the invoice into text format.To do that you can use the file system object.

from project reference select Microsoft scripting runtime.

from the general declaration write the following code.
Dim fso As New FileSystemObject
Dim ts As TextStream


write the following code into any buttonclick event.

Set ts = fso.CreateTextFile(App.Path & "invoice.txt")
      
      ts.Write Space(0) & Chr(15) & "Bill No  : " & rs(0) & Space(11) & billstat & Space(12) & "Phone : " & rs(6) & vbCrLf & vbCrLf
      ts.Write Space(25) & rs(4) & vbCrLf   'Company Name
      ts.Write Space(15) & rs(5) & vbCrLf & vbCrLf 'Address

ts.write vbcrlf


....
....
....

Note : In this example i have used the recordset values.(rs(0),rs(1) etc.

Now the text file is ready.

If you print the text file directly from VB you won't get fast. So you have to print the text file from DOS prompt.

Write a printing command in a BAT file and run it from VB.

To do that

make a bat file called invprint.bat and write the following command.

type invoice.txt > prn

then save the file.


If you run the batch file from VB you will get the fast printing.

write the following code into the buttonclick event

dim fp as string
fp = Shell("invprint.bat", vbHide)


Best wishes
  

[Edited by Chris_871 on 14-01-2003 at 09:32 AM GMT]

09-03-2003 at 06:03 PM
| Quote Reply
saj
Level: Guest

icon Re: Dos based printing

Yes  it will work
but what you will do with the vbhide.  You are hiding a screen.  When you have 100 invoices to be printed you have to hide the dos window 100 times which will result in stopping of printing.
How can you avoid vbhide.  Is there a way to do that.
Please let me know
Regards

09-03-2003 at 06:06 PM
| Quote Reply
ReaperAlex
Level: Guest

icon Re: Dos based printing

insteat of passing vbhide run the bat file 1 time, then edit the pif file to close the dos window on exit.  the only draw back is the user sees the dos screen flash up then disappear.  also try putting all the invoices into the same file, this works fine for me (30 invoices at a time) and i expect 100 would be fine aswell.  with the old dos printers all u have to do is know how many lines each invoice needs, then when u compile the txt file making sure each invoice is teh right length, don't mess with page breaks unless u have to.

hope this helps, ReapeR

10-03-2003 at 01:19 AM
| Quote Reply
chiragcp
Level: Guest

icon Re: Dos based printing

quote:
rana wrote:
Hi i want to know how print dos based i.e. fast printing using vb

does it work properly on printer my setting changes while using batch file
07-05-2003 at 05:13 PM
| Quote Reply
AndreaVB Forum : Printing : Dos based printing
Previous Topic (Printing On Labels)Next Topic (How do I programatically modify printer settings from VB?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder