472,145 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

How to avoid paper ejection after printer.enddoc

Hi buddies,

I am doing a project in vb6 for a restaurant. They are using continous paper roll of 5" width for billing. They need multi language printing. I tried it with Crystal report and even using printer.print command. As the bill is not having default size, i couldnt set a predefined paper size. When i give printer.enddoc the dotmatrix printer ejects enormous paper. I had searched many sites regarding this. Oops! no use.
Plese my buddies help me to make it succeed.

note: my competetor suceeded on this in various projects
Aug 12 '10 #1
16 9602
Guido Geurs
767 Expert 512MB
What type of printer is it?
Is it possible to find details of the codes that can be send to it?
I know that on my old-old-old printer (9 pins Star NL-10) it was possible to send control codes for the page length like = [ESC] "C" chr$(0) n .
Sets page length to n inches.
Aug 12 '10 #2
dear ggeu
its dotmatrix printer and you cant use escape sequence hence its printer.print command
thanks for try
Aug 12 '10 #3
Guido Geurs
767 Expert 512MB
I have found this in: http://www.bigresource.com

I don't think you can use the PRINTER object.

Try opening the PRINTER as a file - with something like OPEN 'LPT1:' AS FILE...

Then do PRINT #1,CHR$(7)

I've never tried this on a PC with VB - but that is the way we talked to old-style printers on mainframes.
Aug 12 '10 #4
Dear ggeu
print # command wont support change of font
because its DOS style Printing
I tried it also.
Thank you again for follow-up

I tried with bigresource also nobody found a best solution for this.

Upto my knowledge, whomsoever going to tell the solution for this, will be the first person on net.
Aug 12 '10 #5
Guido Geurs
767 Expert 512MB
Do you know the ASCII code for "End of page" for your printer?
Once we know this, the only problem is the way how we must talk to the printer.

some say: (http://www.xtremevbtalk.com)

Well, the "best" way to do this, is to use s.c. Escape characters (defined in the printers manual) and send them to the printer directly. This means, if the printer is attached via LPT port, you send commands to it just like you would print to the plain text file. Something like this:
Open "LPT1" For Output As ...
Print #1, "Hello!"
Print #1, Chr$(10) 'line feed
Close #1
and if your printer is on COM port, You'd use MSCOMM component to output those same commands.

As I said, those commands are usualy listed in the printers manual.
Aug 12 '10 #6
Hi ggeu
I am extremely happy with your intention on my query.
But I like to inform you that I need different fonts of different columns. Your code I think, wont supports Windows fonts. Please keep in touch on this.
Aug 12 '10 #7
Guido Geurs
767 Expert 512MB
Are you using a form print ?
I have used this for a print in a game.

Expand|Select|Wrap|Line Numbers
  1. '§ Send a PRINTSCREEN-Window to the printer
  2. Private Sub Com_print_Click()
  3. '§1 Save Print Screen Window in Clipboard
  4.    On Error GoTo Print_Error
  5.    Clipboard.Clear
  6. '§ call the Windows keybd_event sub, passing the built-in
  7. '§ VB keyboard constant vbKeySnapshot (44) to the sub and 1& for the window catch.
  8.    keybd_event vbKeySnapshot, 1&, 0&, 0&
  9. '§ pause to let Windows update the clipboard
  10.    DoEvents
  11. '§2 retrieve the clipboard bitmap to the Picture
  12.   With Picture_print
  13.       .Picture = Clipboard.GetData(vbCFBitmap)
  14. '§3 Wake up printer
  15.       Printer.Print
  16. '§ print
  17.       Printer.PaintPicture .Picture, 1000, 1000
  18. '§ close printer
  19.       Printer.EndDoc
  20.    End With
  21. Exit Sub
  22. Print_Error:
  23.    If Err.Number Then MsgBox Err.Description, vbOKOnly, "Printer Error!"
  24. End Sub
it's also using Printer.Enddoc !!! but it sets the picture size.

You can change the form size depending on the lines to print !

Or is it the command "printer.enddoc" that is misunderstand by the printer.
If so, do you have the right printerdriver for Windows xx ?
Aug 12 '10 #8
any how i got a solution
With Win98 printer.print works well.
I donna know why its not with windows xp
Aug 13 '10 #9
Guido Geurs
767 Expert 512MB
Maybe the version of the printerdriver (not compatible with XP) ???
Aug 13 '10 #10
not like that, because i am using in-built driver "EPSON COMPATIBLE 9 PIN" driver in both OS
Aug 14 '10 #11
I have over come this problem,
Method 1:
You can use Server Properties in the Printer and Faxes Menu in XP to define a custom paper size and call in your report writer. This works 100% for me.

Method 2:
You should print the bill in text format and redirect it to the printer by the DOS command :TYPE MYBILL.TXT>>PRN.
This method is very easy and the print out is faster rather than the windows print. There are also some fonts which prints faster like dos printing. Try those fonts.

Aug 17 '10 #12
Dear Venki
Thank you for your msg.
But understand me I have to print english and tamil fonts with the bill. so your Text print option wont apply me.
Then I am not having fixed length of paper as its roll paper and the print has to end at the end of bill.
Plz Help me!
Aug 18 '10 #13
Stewart Ross
2,545 Expert Mod 2GB
Hi Gevanand. I think our posters have made all the suggestions they can to assist you with what is a very unusual request. That you can print using the methods listed to an old 9-pin dot-matrix printer at all is something of a miracle. I note that this is a project you are undertaking - even if we had a complete solution, it would not be in keeping with the spirit of your project for you to keep asking others to solve it for you!

Aug 18 '10 #14
Dear Stewart
It works fin with Windows 98SE.
But not in XP thats y i am confusing
Aug 19 '10 #15

First of all, sorry for my English.

I reached this thread because I had the same problem.

I'm using an application writeen in access2 and in some cases, where the application does the EndPage or the EndDoc it sends some Chr(10) to the printer.
Some printers ignore Chr(10); only in case of Chr(13) & Chr(10) it feeds the paper. Some printers ignore Chr(10).

But I observed that the same printer that has the problem can work in some cases.

Solution (I do not know the exact names in english, I use the XP in Spanish):

1- Go to the Printer properties.
2- Device configuration.
3- There should be an Option (First one) named "Continuous Feed" or some like that. Yo should choose a Continuous paper, Not A4. I Use "Continuous USA Standard".
Sep 1 '10 #16
you must use print using form method to stop the roll paper in your dotmatrix printer. i mean using WIN32 API to add your custom paper size to the registry, but the problem is when you select your custom paper size it doesnt appear in the printer you selected. look like its appear in the global paper size on the registry but not for your printer, try read article "How To Print Using Custom Page Sizes on Windows NT and Windows 2000"in microsoft developer network website.
Oct 18 '10 #17

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Patrick Herb | last post: by
4 posts views Thread by Lizard King | last post: by
5 posts views Thread by Tom Berry | last post: by
2 posts views Thread by Daniel Iwan | last post: by
reply views Thread by shanavaspi | last post: by
23 posts views Thread by Al Grant | last post: by
reply views Thread by Saiars | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.