Printing to a dotmatrix printer from VB.NET application

Good Afternoon,

I have developed a Cheque printing program in VB.Net and need to print the output for the cheque to a dot matrix printer (Oki Microline 390 Turbo).

The output is only text and I am using the “Generic / Text Only” driver to communicate with this printer under Windows 7 (32-bit).

I’ve managed to figure out some very basic code for printing the output (below) and this works fine.
Private Sub ctrlPrintDoc_PrintPage(sender As System.Object, e As Printing.PrintPageEventArgs) Handles ctrlPrintDoc.PrintPage

        Dim N2WResult As String

        N2WResult = AmountInWords(txtMAmt.Text)

        e.Graphics.DrawString(txtMChqNum.Text, New Font("Courier", 10), Brushes.Black, New Point(100, 50))
        e.Graphics.DrawString(DateTimePickerM.Text, New Font("Courier", 10), Brushes.Black, New Point(100, 100))
        e.Graphics.DrawString(N2WResult, New Font("Courier", 10), Brushes.Black, New Point(100, 150))
        e.Graphics.DrawString(txtMPayTo.Text, New Font("Courier", 10), Brushes.Black, New Point(100, 200))
        e.Graphics.DrawString(txtMRef.Text, New Font("Courier", 10), Brushes.Black, New Point(100, 250))
        e.Graphics.DrawString(txtMAmt.Text, New Font("Courier", 10), Brushes.Black, New Point(100, 300))
      
    End Sub

Open in new window

However this will not do, as I need more control, for the margins, positioning etc.

I’ve downloaded the manual for this dotmatrix printer and have the ESC codes for the different options but don’t have a clue on how to implement them in my code.

Is someone familiar with accomplishing this for a dot matrix printer?

Kindly Advise,

Regards,
N
LVL 1
KevinAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ktaczalaCommented:
Check out this MS article.  I've not needed to do this but, it looks like it will point you in the right direction.
https://support.microsoft.com/en-us/kb/322090
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ktaczalaCommented:
Here's another article of a person trying to do the same thing as you.
http://www.codeproject.com/Questions/169760/Print-and-send-commands-to-receipt-printer
0
KevinAuthor Commented:
Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.