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
.Margins.Left = 100
.Margins.Right = 100
.Margins.Top = 0
New System.Drawing.Printing.PaperSize("PaperA4", 8.5 * 100, 12 * 100)
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
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
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...
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.....
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:
ESC @ Initialize Printer.
ESC U0 Set Unidirectional printing 0 = off 1 = on
ESC EM Control cut sheet feeder 0 = off 4 = on
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 + ?
ESC Cn Select page length in n lines. n = 1 to 127
ESC Q Set right margin n = column
ESC 1 Select 7/72 inch line spacing.
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 Dn 0 = clear tabs, else up to 32 horizontal tabs (1-137.)
ESC Bn 0 = clear tabs, else up to 16 vertical tabs
ESC Jn n = immediate n/216 inch line feed
ESC kn 0 = NLQ Roman/1 = NLQ Sans Serif
ESC xn 0 =draft mode/1 = NLQ mode
ESC ! n n = 0/1/4/8 pica/elite/cond/emph
The Epson LQ 680 also emulates IBM Proprinter 2390 Plus.
Answer 5Dim 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
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.
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
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
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
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
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.
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
.PaperSize = p
then using this code to print
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
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
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.
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
Firstly I create a BAT File like below. Name is billout.bat
rem MODE COM1:9600,N,8,1
rem copy %1 COM1
REM TYPE %1 > LPT1
REM TYPE %1 > \\ServerName\PrinterName
rem copy %1 LPT1
I want to print what i select from billout.bat. (if it is Without "rem", it will be printed.)
Secondly I have below text for printing for example.
1) Customer name and address for Top Area of page.
2) Stock name, amount and price for Middle Area of page.
3) Total prices of Stock for Down Area of page.
Now i need Csharp codes example to print with this method(with billout.bat).
Note: I need below.
1) Page height and weight. Height should be as line of page. And Weight should be as coulumn of page.
2) Which text print to which line and column.
3) if stock numbers more than one page, what should i do ? How can i see that stock numbers more than page height line ?
Lastly i have example codes related to this issue. But it didnt solve my problems. My example codes are below.
Below code is working odd in windows forms.This code is printing odd ASCII characters
streamToPrint = new StreamReader("C:\\test.txt");
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
catch (Exception ex)
privatevoid pd_PrintPage(object sender, PrintPageEventArgs ev)
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
string line = null;
// Calculate the number of lines per page.
linesPerPage = ev.MarginBounds.Height /
// Print each line of the file.while (count < linesPerPage &&((line = streamToPrint.ReadLine()) != null))
yPos = topMargin + (count *
ev.Graphics.DrawString(line, printFont, Brushes.Black,leftMargin, yPos, new StringFormat());
// If more lines exist, print another page.if (line != null)
ev.HasMorePages = true;
ev.HasMorePages = false;
Our application runs on a terminal server session and need to send the receipt printing back to the local desktop. We may have more than 10 different logical names on terminal server session that should print the receipts back to local desktops. Solution
works fine on a local desktop where the devices are attached. Can someone give us detailed steps to set up receipt printer to meet this requirement...
Any help is greatly appreciated as we are in a time crunch for release
POSControlException ErrorCode(Illegal) ExtendedErrorCode(1001) occurred: The port name is illegal, or couldn't be connected to the device.
jp.co.epson.pos.comm.CommControlException: The port name is illegal.
Opened device: TM-H6000III
Created instance of device: TM-H6000III
I am having a problem - I need to know if I can redirect an EPSON TM-T88IV (Parallel) printer attached to a Windows 2000 Professional (x32) client to a Windows Server 2003 (x64). I've tried to get this to work but it is not working. Can anyone explain
to me what tools I will need and what I need to do to get this to work.
I have already downloaded the EPSON OPOS ADK for .NET - I have also downloaded the Microsoft POS for .NET andinstalled on both the client and the server but I am still unable to get it to work.
Good Day,Read more...
Can anyone advise as to how I would include the the ASCII charater for the £ sign in a line that is being printed on an epson receipt printer, in C#. I am using the raw print method as decribed in this article :
I am new to POS printing. I searched around on this forum and as advised, installed Epson ADK for .Net from EpsonExpert.com and also installed POS for .net.
The problem I have is that I don't know if my printer is connected to my computer properly. I have an Epson TM-U230 that has a 25 pin serial port. My laptop only has usb. So I connected the printer to the laptop using a serial to usb plug (serial at the
printer end and usb at the laptop end). I am not sure if this worked. Is there anyway I can print a test page? As stated earlier I already installed OPOS ADK for .Net. Are there any additional drivers that I need to install for this printer?
I will be greatful for any suggestions.
i want my report to be 132 colums wide ie fanfold 15x12 inch.
How do i change the size of my report.
so my questions are :
1.How do one can change the size of report
2.How do one can change it's orientation. (portrait)
if i try with paper size 15x11inch its showing inproper page breaks. or by setting bottom and top margin its splitting into multiple pages.
Please help.Read more...
When can we expect fix or quick work around for this, Is this available in Office 2010 ?Read more...
how to code in visual basic to take printout of a text file in visual basic using dot matric printer and hp laser printersRead more...
Hi i am a newbie at all for printing codes and i dont know where to start printing, so i need somebody to give a very good and brief clear instruction to how and where to put my records for printing, i was coming up to think about creating a listview with white boarders at a Form with None Style but unfortunately my height is stable size and i want it auto size for my receipt. anyone could give me a better idea for printing? or better format to arrange my recrods for bill number? i have heard from my friends that i have to code my format for the receipt before printing it i dont even know what and how many tools to use before printing and coding it, i hope for your considerations. i just need some instruction.
hi i m using this this coding to copy and print the word document
"\PrintT.doc", Application.StartupPath & "\PrintT1.doc", True)
Dim line1 As String
Dim line2 As String
line1 = "Line1 Replace"
line2 = "Line2 Replace"
Dim objWordApp As New Word.Application
objWordApp.Visible = True
'Open an existing document.
Dim objDoc As Word.Document = objWordApp.Documents.Open(Application.StartupPath & "\PrintT1.doc")
objDoc = objWordApp.ActiveDocument
'Find and replace some text
'Replace 'VB' with 'Visual Basic'
objDoc.Content.Find.Execute(FindText:="Line2", ReplaceWith:=line2, Replace:=Word.WdReplace.wdReplaceAll)
objDoc.Content.Find.Execute(FindText:="Line3", ReplaceWith:="Line3 Replace", Replace:=Word.WdReplace.wdReplaceAll)
'Save and close the document
objDoc = Nothing
objWordApp = Nothing
now i need to print the Word Document with Printer Default Font(Draft 17.5 CPI) in Dot Matricx PrinterRead more...
I try to silently install a USB Printer using WMI and I encounter an ennoying issue :
Everything is done well (USB connection event interception, disabling Windows New hardware installation wizard through registry key, driver and printer installation via WMI).
But when I shutdown the printer and restart it, it is redetected by windows and the New hardware installation wizard is launched.
We have tried installing the printer with addprinter api and also Printer installation wizard in silent mode but it leads to the same issue.
We made a little application that demonstrate this. You can download it at
Here is an extract of this code, regarding WMI Printer installation :
connectionOptions = new ConnectionOptions();
connectionOptions.EnablePrivileges = true;
managementPath = new ManagementPath("Win32_Printer");
managementScope = new ManagementScope("\\root\\CIMV2", connectionOptions);
printer = new ManagementClass(managementScope, managementPath, null).CreateInstance();
putOptions = new PutOptions();
putOptions.Type = PutType.UpdateOrCreate;
Here are the steps to reproduce the problem :
1. Launch my application
2. Follow the steps in my application to detect the usb printer, install the generic/text drivers, and install the printer.
3. Restart the printer, windows detects again the printer as a new hardware.
4. If I complete the windows new hardware installation wizard, a restart of the printer doesn't display the wizard.
I think some registry keys are missing when using the WMI installation but cannot figure out which.
It would be kind if someone could help me on this issue,
Thanks in advance !
CheckHealth(3) = 114
ResultCodeExtended = 0
Error log ---> Drawer status HIGHRead more...
I am new to OPOS. Currently I am working on Pritning a receipt, after printing the receipt the Cash Drawer should open automatically. I completed code for printing the receipt using Epson Tm-T88IV printer. But I am unable to do for Posiflex Cash Drawer Open.
Could some one help me on this. Please post the sample code, if available.
I would appreciate any help you could give me.Read more...
Hi .NET superstars,
I'm absolutely new to .NET and world of printing. I basically need to printer some information in a receipt-like paper (almost half of the A4 size). Printer that I've is Epson LX-300 +. I've searched these forums & realized I need to download two things a)- Microsoft POS.NET b)-ESPON OPS ADK for .NET and I did download these two. So far so good.
So I've three questions
1- Has anyone programmed using Espon LX-300 +? How is the process like? I'm a junior programmer but what I can see from source code samples is that you basically send a plain text to printers? Furthermore, paper sized aren't specified in the source code, right? I mean how do we control paper-size in LX 300 + --from Printer Prefences?
2- I downloaded ESPON OPOS ADK.NET
. After the download I can see application programming guides for all kinds of printers but I don't see a programming guide for LX 300 +. Can you please help me in locating the application programming guide for LX 300 +.
3- I attached the printer with PC and then opened up "SetupPOS" utility. In that utility, when I click on "Add Device" button it pops up a screen that contains various device names. However, among those device names I don't see "LX 300 +". Any ideas what should I do in this scenario?
I'm sorry if these sound like easy questions but I honestly have no clue. So I will really appreciate any help in this regard.
Using POS for .NET 1.12 and the Epson OPOS ADK for .NET (v1.11.9) service-objects
I'm able to successfully Open, Claim and Set the DeviceEnabled-true for my PosPrinter, however I'm having trouble sending anything to the printer after this. A Call to PrintNormal() results in a 'It is not initialized' exception being thrown. In fact, the CheckHealth Utility that came with the Epson OPOS ADK results in exactly the same error.
I can print fine to the printer using direct serial IO, so I know it's not a problem with the printer itself.
Has anyone seen this behaviour before / shed some light as to what may be going wrong?
I have a Cash Drawer configured using the SetupPOS application and connected through a TM-H6000III multifunction printer.
When I do not have the printer connected to my computer and try to access the cash drawer it throws a PosException at the cd.claim(1000) method which is handled correctly after which I close my application and found out that the process is still running
in the Task Manager and needs to be manually terminated. This only happens when the printer (through which the drawer is connected and configured) is not connected to the computer.
Also when I try to run this in the debug mode the form closes but visual studio is still running.
Has someone faced a similar case or has any idea why this is happening.
Thanks and Regards,
I am running Visual Studio 2010 on Windows 7. I have installed POS for .NET SDK and the Epson OPOS for .NET.
I have used the Epson SetupPOS.exe to give my TM-T88IV a logical name. I have then used the CheckHealth utility to print to the device and everything seems fine so far.
I have then run the TestApp.exe sample program from the POS for .NET SDK. The program lists my printers logical name "JdeCPosPrinter" and i can "Open", "Claim" and "Enable" it and then print out some sample text.
My problem is when i try to write a procram in C# it cant seem to find the device. If i execute the following code only the microsoft simulator devices are listed.
static void Main(string args)
PosExplorer myExplorer = new PosExplorer();
DeviceInfo prtDeviceInfo = null;
foreach (DeviceInfo deviceInfo in myExplorer.GetDevices())
What am i doing wrong? Should i be referencing the Epson drivers somewhere in my code? Any help would be much appreiciated.
I have an Epson TM-88III printer (Serial) with a cash drawer connected to the back of the printer (I think its an RJ11 connection), I'm using POS for .NET 1.12 & Epson OPOS ADK for .NET, everything is working fine as far as printing receipts with logo, barcode and text but I am unable to find any reference to sending the command to open the cash drawer. How do I get the printer to open the cash drawer when the receipt has printed?
Im using VB.NET (2008) and the following code to send text for the receipt (as used in Epson examples), I have omited the opening and claiming commands:
PosPrinters1.TransactionPrint(PrinterStation.Receipt , PrinterTransactionControl.Transaction)
PosPrinters1.PrintNormal(PrinterStation.Receipt, ESC + "|1B")
PosPrinters1.PrintNormal(PrinterStation.Receipt, ESC + "|N" + "123xxstreet,xxxcity,xxxxstate" + vbCrLf)
PosPrinters1.PrintNormal(PrinterStation.Receipt, ESC + "|rA" + "TEL 9999-99-9999 C#2" + vbCrLf)
PosPrinters1.PrintNormal(PrinterStation.Receipt, ESC + "|200uF")
PosPrinters1.PrintNormal(PrinterStation.Receipt, ESC + "|cA" + Now.ToLongDateString + vbCrLf + vbCrLf)
PosPrinters1.PrintNormal(PrinterStation.Receipt, ESC + "|200uF")
PosPrinters1.PrintNormal(PrinterStation.Receipt, ESC + "|500uF")
PosPrinters1.PrintNormal(PrinterStation.Receipt, ESC + "|fP")
PosPrinters1.TransactionPrint(PrinterStation.Receipt , PrinterTransactionControl.Normal)
I would appreciate any help you could give me
We sell a complete POS system that we have been running successfully for years on 2003 std. and RDP connections via thin clients. We recently started looking into upgrading our approach to 2008 x64 and using 8GB of ram.
My problem right now is that we use EPSON printers, and the setup utility (Epson.opos.tm.setpos.exe) for them doesn't seem to work on x64 systems. I can't seem to find anyone at EPSON that even knows what I'm talking about, has anyone else run into this problem?Read more...
I have this problem:
Epson display DM-D110
I download driver from Epson web site. I install and now system can see this hardware.
I'm using Putty.exe to check if virtual serial com port (in my case COM22) is working or not........and everything should be fine......
I create a project with Microsoft Point of Services for .Net
posExplorer = New PosExplorer
deviceInfo = posExplorer.GetDevice(DeviceType.LineDisplay, strLogicalName)
m_Display = posExplorer.CreateInstance(deviceInfo)
Catch ex As PosControlException
and the Messagebox show : The port name is illegal, or couldn't be connected to the device.
can someone help me ?????????
thank you in advance