Dot matrix printers

  • Thread starter Thread starter Joza
  • Start date Start date
J

Joza

Hi!

Can somebody give me a piece of code how to send data to dot matrix printers?
I have used google for example but nothing that can help me. I'm using C#.

Thanx.

J.
 
Joza said:
Can somebody give me a piece of code how to send data to dot matrix printers?
I have used google for example but nothing that can help me. I'm using C#.

Hi Joza,

Your Windows application should use the same API for printing to a dot
matrix printer that it does to print to any other printer. As long as
you have the proper Windows driver for your printer, there's nothing
special that you need to do.

The classes that handle printing are found in the
System.Drawing.Printing namespace.

Hope that helps,
 
senfo said:
Hi Joza,

Your Windows application should use the same API for printing to a dot matrix printer that it does to print to any
other printer. As long as you have the proper Windows driver for your printer, there's nothing special that you need
to do.

The classes that handle printing are found in the System.Drawing.Printing namespace.

Hope that helps,

Thanx Sean, now I know where to start, but here is another problem; do I must send some
printer esc sequences to printer? If so, what to do if I use several type of printers; for instance,
Epson, Fujitsu... I think that they use different esc seq. I'm asking that because I have created
report in Crystal Report, and report must be printed on A3 paper size. But printing is slow and
I cannot define properly page size through CR. I must use printers options in control panel to
set the page size but that is not good for my users because they do not know how to do that,
especially beacuse some of they have a Epson, some Fujitsu and other types... and for each
printer the options are different. So I must make something unviersal.
 
Joza said:
Thanx Sean, now I know where to start, but here is another problem; do I must send some
printer esc sequences to printer? If so, what to do if I use several type of printers; for instance,
Epson, Fujitsu... I think that they use different esc seq. I'm asking that because I have created
report in Crystal Report, and report must be printed on A3 paper size. But printing is slow and
I cannot define properly page size through CR. I must use printers options in control panel to
set the page size but that is not good for my users because they do not know how to do that,
especially beacuse some of they have a Epson, some Fujitsu and other types... and for each
printer the options are different. So I must make something unviersal.

Hi Joza,

Not a problem, at all. The beauty of using the API is that you don't
have to worry about what language the printer speaks! Page size, etc.
is all provided to you by the classes.

As an example, try this:

1) Start a new VS Windows application
2) Add a TextBox and a Button control to the form
3) Add a PrintDocument component to the form
4) Add code to the buttons Click event handler to print the page. Your
code should look like this:

private void btnPrint_Click(object sender, EventArgs e)
{
printDocument1.Print();
}


5) Add code to the PrintDocuments PrintPage event and add code to handle
print event. Your code should look something like this (don't forget to
add your using directive for the System.Drawing.Printing namespace):

private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
// Create our default font
Font fnt = new Font("Arial", 10, FontStyle.Regular,
GraphicsUnit.Point);

// Notice additional properties provided by PrintPageEventArgs
e.Graphics.DrawString(txtMyText.Text, fnt, Brushes.Black, 0, 0);
e.HasMorePages = false;
}

To make things interesting, you might want to consider setting the
MultiLine property of the TextBox to true so that it supports more than
a single line of text. At any rate, however, this should print
something, regardless of the kind of printer you have.

One important thing to note is that the PrintPageEventArgs class
provides MarginBounds and PageBounds properties that can be used to
specify the page settings that you desire.

Hope that helps,
 
</cut>

Thanx again Sean, some things became clearly to me now. I have also found an
example at msdn for raw printing. Now my task is to get idea how to
send whole resultset in columns like to the printer... This is so
complicated and makes me headache.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top