Home » VB.NetRSS

Epson LQ680 Dotmatrix Printer


am facing a problem while am printing from Visual Basic 2005  to one Epson LQ680 Printer (Dotmatrix).
every time am printing lines are not coming at the proper place and keeps on moving up or down randomly

paper size is not A4 it is  8.5 Inch Width, 12 Inch Height

some times it is printing fine, but after priting 2 or 3 invoices again it is moving every line 1 cm down...etc
it moving up and down only left and right ok

it is out of my control


With PrintDocument1.DefaultPageSettings

.Margins.Left = 100
.Margins.Right = 100
.Margins.Top = 0

.PaperSize =

New System.Drawing.Printing.PaperSize("PaperA4", 8.5 * 100, 12 * 100)

EndWith

Dim AmountENFont As Font = New Font("Arial", 10)
Dim ENFont As Font = New Font("Arial", 10)

Dim string_format AsNew StringFormat()
string_format.Alignment = StringAlignment.Near
string_format.LineAlignment = StringAlignment.Near

'== Beneficiary ==
e.Graphics.DrawString((frmApp.txtBeneficiaryName.Text.Trim), ENFont, Brushes.Black, 260, 380, string_format)

e.Graphics.DrawString((frmApp.txtBeneficiaryAC.Text.Trim), ENFont, Brushes.Black, 260, 460, string_format)

e.Graphics.DrawString((frmApp.txtBeneficiaryBank.Text.Trim), ENFont, Brushes.Black, 260, 485, string_format)

e.Graphics.DrawString((frmApp.txtBeneficiaryBankadd.Text.Trim), ENFont, Brushes.Black, 260, 510, string_format)

e.Graphics.DrawString((frmApp.txtBeneficiaryBankCountry.Text.Trim), ENFont, Brushes.Black, 260, 530, string_format)



any one can help?


 

11 Answers Found

 

Answer 1

Hi

Download this PDF printing program, and print to a PDF file insted... If the same error applies then there is someting wrong with you printer... I not there is somerthing wrong with application:

Download the software here
 

Answer 2

when i print to any laser printer with A4 Size it printing fine,
i have noticed something, if i will switch off the epson printer after each print command the application will print fine
and lines come at its proper place !!!

otherwise it will keeps on moving lines down 1 cm or less each time but after 4 or 5 print out it will return to the correct place

is there any command in VB to inform the printer that print operation has been finished and to reset the margines again...

 

Answer 3

Does this happen with office doc or any other filformats which is not related to VS? If so throw the printer in the bin.... or costumer support at Epson.....
 

Answer 4

The moving in small increments is probably microjustification which many dot-matrix printers did to try to keep the lines consistent in the vertical plane. Why it is occurring is a mystery to me, but tell me about the driver...is it for that make and model? I think that you are probably printing to it using bad default parameters for the stock you are using.

It might be a good idea to find out what the Escapes for enabling things like microjustification are, and you might also have to revert to a GDI print model, at least to end the escapes that will configure the printer the way that you need to. Epson has its own printer language that is managed with escapes in the case of your trusty ole dot-matrix, probably.

EDIT : I have downloaded the owner's manual for your printer, and it does indeed support both Epson and IBM escapes. Here is an incompletely documented list of the escapes supported by that printer. It is possible that your document has escapes embedded in it. Look at the area where you said it starts moving vertically, for example. There is an escape that does this exact thing you are talking about...its ESC Jn, where n is the number of 1/216 inch to move the printhead.

If you would like to configure the printer for A4 size paper using escapes, you can use the GDI function ExtEscape using the value PASSTHROUGH after filling a buffer with the escape character sequence. You might also study the chart below, and come up with a series of escape to configure it to do what you want it to do prior to printing this specific job.

The Epson LQ 680 supports the following EPSON ESC/P2 control codes:

General Operation:
ESC @			Initialize Printer.
ESC U0			Set Unidirectional printing 0 = off 1 = on
ESC EM			Control cut sheet feeder 0 = off 4 = on

Paper Feeding:
FF
LF
ESC 0			Select 8 lines per inch
ESC 2			Select 6 lines per inch
ESC 3n			Select n/216 lines per inch n = 0 to 255
ESC +			?
CR

Page Format:
ESC (C
ESC Cn			Select page length in n lines. n = 1 to 127
ESC C0
ESC Q			Set right margin n = column
ESC 1			Select 7/72 inch line spacing.
ESC (c
ESC Nn			Skip over perforation n = 1 to 127.
ESC O			Cancel skip over perforation.

Print position motion:
ESC $			Select absolute dot position.
ESC \			Select relative dot position.
ESC (V
ESC (v
ESC Dn			0 = clear tabs, else up to 32 horizontal tabs (1-137.)
HT
ESC Bn			0 = clear tabs, else up to 16 vertical tabs
VT
ESC Jn			n = immediate n/216 inch line feed

Font Selection:
ESC kn			0 = NLQ Roman/1 = NLQ Sans Serif
ESC xn			0 =draft mode/1 = NLQ mode
ESC y
ESC X
ESC P
ESC M
ESC g
ESC p
ESC 4
ESC 5
ESC E
ESC F
ESC ! n			n = 0/1/4/8 pica/elite/cond/emph

Font Enhancement:
ESC W
DC4
SO
DC2
SI
ESC w
ESC G
ESC H
ESC T
ESC S
ESC -
ESC (-
ESC q

Spacing:
ESC Space
ESC c
ESC (U

Character Handling:
ESC t
ESC (t
ESC R
ESC %
ESC &
ESC:
ESC 6
ESC 7
ESC (^

Bit Image:
ESC *

Bar Code:
ESC (B

The Epson LQ 680 also emulates IBM Proprinter 2390 Plus.
 

Answer 5

Dim BeneficiaryAddWidth AsSingle = 500.0F
Dim BeneficiaryAddHeight AsSingle = 100.0F
Dim drawRectBeneficiaryAdd AsNew RectangleF(260.0F, 410.0F, BeneficiaryAddWidth, BeneficiaryAddHeight)

e.Graphics.DrawString((txtBeneficiaryAdd.Text.Trim), ENFont, Brushes.Black, drawRectBeneficiaryAdd, string_format)


the whole problem was caused by the last line, when it comes to drwa RECT the printer was making that problem

i think it RWA printer only and dont supoorting such a drwaings
when i removed this line it is printing fine

thanks a lot everybody

 

Answer 6

If you had put that line in in the first place, I could have figured that out. You probably do have an escape embedded in there.

No, the printer can handle graphics, but you cannot just make that transition from text to graphics without those escapes that I have provided for you. The escape to switch to bit image mode is ESC *. The graphics capabilities of a printer are available through the standard Win32 API, using GetDeviceCaps.

I suppose that as long as you are satisfied with that as an answer, I am, too.
 

Answer 7


can you give us a sample code in VB how to use those Epson LQ 680 ESC/P2 control codes
i didn't understand you much,  those control cods looks very intersting but i don't have any idea about them

Thaanks

 

Answer 8

Let me make a few things clear first, because this is likely to involve more than just that.

First, that printer is absolutely ancient by the standards that ordinarily show up in a forum that is dedicated to using VB.NET in the IT industry. (I'm sure that you know this already.) However, things being the way they are, printers get used until they don't print anymore, and most businesses get by using equipment that they already own, and programmers like you and I need to be able to get the job done, especially when it gets tedious...like now.

Dot-matrix printers have widely varying capabilities, which is why I mentioned GetDeviceCaps in the Win32 API. I must admit to you that I know far less about .NET than the Win32 API. I responded to your post because I suspect that you will need to use Win32 for this printer. For one thing, there is the issue of these escapes I keep talking about. Another thing is that some printers require a technique called banding for output, but I doubt that is the case with your Epson. GetDeviceCaps will tell you that very directly. (You must make a call to GetDeviceCaps for each type of capability you want to know about.)

As you have seen, text output to this printer works as expected. It is the graphics capabilities that we are unaware of, and I need to make a side trip into how printing is done 'under the hood' in order to make this more clear to you.

In Windows, the output device is abstracted (hidden, more or less) through device contexts. (A display and printer use the same type of device context, which is implemented in the driver.) The device context is your path to the device...through the driver. DrawText is GDI+, but eventually, it will call TextOut, ExtTextOut or DrawText from GDI. You can use strings, and it will get printed in whatever font is selected into the device context at the time the call is made. I have not tried sneaking escapes into normal text output, but I suspect that it is not simple to do, if it is even possible at all. (It would involve sneaking ASCII code 27 into what is otherwise a normal string. Where you see the word ESC, it means ASCII code 27, or just the value 27.) So then, when I said that you needed to send ESC * to switch to bit image mode, that means to use 27 32 42 0 FYI, text is a special form of graphics, where the text is painted (called rasterization) by the device driver...not Windows.

The functions that you use for sending escapes are from the GDI (gdi32.dll) component of Windows. They are Escape and ExtEscape. Escape is for pre-defined system escapes that Windows already knows, and that are standardized across all printers. (STARTDOC/ENDDOC, NEWFRAME, ABORTDOC, etc.) ExtEscape is for sending specific escapes, like the ones in the chart I made for you.

Now, as far as printing in GDI, there are a few places that you need to work on so that you know what you are dealing with more precisely. The first thing that you need to do is get a handle to a device context for that printer. After that, you can use GetDeviceCaps and/or DocumentProperties to (optionally, display the printer settings dialog, which is from the driver.) set the printer up with the proper settings. GetDeviceCaps will tell you if there is graphics capability, and the extent of that capability. DocumentProperties can be used to set your stock up, and some other things, too...it depends on your driver, and its not very easy to use at all. (I have developed a method, but unless you know the format of the extra information...it might not be of much use as a replacement for the escapes that you will have to use anyway.)

Okay, I have made a lot of work for myself...I will select functions from GDI and give you some sample code that you can use to get this figured out. One thing I want to make clear is that one of the [only] advantages of writing this code is that the escapes are standardized across all printers that support the Epson ESC/P2 control set, which is a lot. The other non-Postscript standard is IBM ProPrinter, which your LQ 680 also supports, and which only differs in the meaning of the codes...the semantics are the same, which is important to you as a developer supporting ancient printing methods.

I will post you some useful code soon.
Cheers.
 

Answer 9

my problem is am printing to paper with size  W: 8.5 Inch, H: 11 Inch

am using this code to specify the paper size in my program

Dim p AsNew System.Drawing.Printing.PaperSize("Custom Paper Size", 8.5 * 100, 11 * 100) 'hundredths of an inch

With PrintDocument1.DefaultPageSettings

.PaperSize = p

EndWith

PrintPreviewDialog1.UseAntiAlias =

True

PrintPreviewDialog1.ShowDialog()

then using this code to print

Private

Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

e.Graphics.DrawString((DateTimePicker1.Text.Trim), ENFont, Brushes.Black, 630.0F, 130.0F, string_format)

e.HasMorePages = False

EndSub

Now the strange thing is it is not printing at the same place as per my settings,
some times it is printing fine (2 or 3 papers) then on the forth print out it is shifting around 1 cm then again it is going back normal
each tow or 3 prints it is repeating this problem

i dont know is there any problem with my code or ......

if any one can help i will really approciate





 

Answer 10

Is that printer a tractor feed printer, does it have a continuous form?

I want to be specific about my questions to you. Are you saying that the code advances the form to those coordinates, prints that text properly, and in the correct font, color, etc., and then advances to the next form most of the time, but that occasionally, there is some up and down movement of the stock before the text is again printed correctly, including the correct font and color? If that is the case, then there is not an issue. That's just the printer driver adjusting the stock to the form size. (The microjustification that I spoke about earlier.) If the printer moves the text also, then the form size has not been setup correctly, or the printer might not be getting reset correctly. Since you say your code works okay with laser printers which use cut sheet stock, incorrect handling of either form size, or the difference between tractor feed dot-matrix and cut sheet jet/laser technology are the most likely source of the aberrant behavior of the code. Another thing, I would also explore the theory that DrawText is using a bitmap internally, so the internal representation of the text does not match the form size of the printer.

I am trying to help in the only way I can, since even I do not have such an old printer. I can help you much more thoroughly and quickly if you tell more about the OS you are using, and also the driver that you are using to print with.

I have some code that I am working on to use the escapes I mentioned. That might be your only way to get consistent results with the particular print scenario.
 

Answer 11

I  have  printing bill   apllication   by  reporting  service  and  vb.net  my  proplem  when I  print  with Epson LQ 680 it take 3 pager or  tow ?can any  one told me how to  make  the  size  of  report  to  fill my invoice  

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter