0

I have a requirement to print a bill on a dot matrix printer in basic mode. I know that Dot matrix printer page can be divided into a matrix of characters and i just want some help on how print on X&Y co-ordinates. It is something like this,

Printer.CurrentX = 1584;
Printer.CurrentY = 3168;
Printer.Print "PARTICULARS";

Does anyone have a sample on how to do this or some a little idea would help me. Thanks,..

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Chandra Eskay
  • 2,163
  • 9
  • 38
  • 58
  • You mean it's a line printer? No graphics? – Mr Lister Jun 07 '12 at 07:11
  • @MrLister : Its an EPSON FX-1000 dot matrix printer – Chandra Eskay Jun 07 '12 at 07:13
  • 1
    related: http://stackoverflow.com/questions/7009593/printing-a-report-to-a-dotmatrix-printer --> gives you someidea. and another@ http://stackoverflow.com/questions/2136942/printing-in-parallel-port-dot-matrix-over-c-sharp – Subs Jun 07 '12 at 07:14
  • @Subs : That is using a ready-made page but what i'm trying to is print each character using specified X,Y co-ordinates.. Second one is some of some help.. Thanks . – Chandra Eskay Jun 07 '12 at 07:16
  • 1
    @Chandu-Indyaah As per the suggestion here @ http://www.foxite.com/archives/printing-to-dot-matrix-printer-in-visual-fo-0000019623.htm --> did you try sending it to a file first and then printing the file? Also see the linked link on the 2nd link in my earlier post or this --> http://stackoverflow.com/questions/246233/dot-matrix-printing-in-c – Subs Jun 07 '12 at 07:24

2 Answers2

1

A dot matrix printer doesn't work that way. The dot matrix is the method of printing on the paper, it's not a matrix that is used to specify output.

To print a page you normally print it from top to bottom, line after line. You don't specify coordinates for the text, you simpy output spaces and line feeds to get to the right character position.

(There are control characters that you can send to the printer to feed the paper backwards, but feeding the paper back and forwards a lot is just asking for a paper jam.)

Guffa
  • 687,336
  • 108
  • 737
  • 1,005
  • Yes, I understood. But, do we need to add a reference to a dll to that and how to send control characters to the printer using code?? – Chandra Eskay Jun 07 '12 at 07:25
  • The second question that Subs linked to has an answer that shows how you can open a stream to the printer. Line feeds can be send using `WriteLine`. Other control characters are simply written to the stream, like a form feed: `stream.Write((char)12)`. – Guffa Jun 07 '12 at 07:32
1

The Printer.CurrentX and Printer.CurrentY are from the VB6 era, they set the coordinates in Twips of where you put your text but does not print untill you use the Printer.EndDoc Method. There is a .Net version of this in the Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6 Namespace that was provided for converted VB6 programs. You could add the NameSpace to your program and use the same functions, but you would be better off using the PrintDocument's Print Method. Since they both are going to print in page mode anyway(by that I mean you setup your data and send the entire page to the printer when you print) .

Mark Hall
  • 53,938
  • 9
  • 94
  • 111