Results 1 to 9 of 9

Thread: Dot Matrix Printing

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Dot Matrix Printing

    I have written an application that prints to dot matrix printers for my client. The problem I am having is that on multi-page jobs, the first page lines up fine, but every subsequent page is one line lower. It doesn't keep creeping down the page, it just does this one time after the first page is printed.

    This is mostly acceptable for reports, but for printing on pre-printed forms, it becomes a pain.

    I searched all over the place and haven't seen any ideas that seem to be able to fix this issue. Hopefully, someone here has run into this in the past and can point me in the right direction. The printers are Okidata 320s and 321s and some Turbo models.

    I have checked all through my code and there doesn't appear to be anything in the code that is causing the issue. It appears that it has something to do with the printer. I have adjusted settings until my fingers hurt and nothing has worked, yet.

    The printer knows where the top of the form is and has the correct paper length set, because if I set TOF and then print a one-page report, it is down one line too many when it has finished form feeding. If I press the Form Feed button on the printer, then it page ejects to the correct position of the next page. It's almost as if there is a Line Feed coming from somewhere. However, I don't have any different code for printing the first page than I have for printing any other page. It is the exact same code.

    I thought the problem might be coming from some of the ESC characters that I am sending to the printer, so I commented them out and it still does it.

    PS - To be able to send the reports directly to the printer, my application actually writes the reports out to a text file and then calls the SendFileToPrinter routine found here http://support.microsoft.com/kb/322090.

    PSS - I am using the Generic/Text Only driver in Windows XP. I have also tried the Epson FX-286 driver and the Okidata driver.
    My.Settings.Signature = String.Empty

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: Dot Matrix Printing

    Can you post the text file?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Re: Dot Matrix Printing

    Let me scrub the data and I will post one.
    My.Settings.Signature = String.Empty

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Dot Matrix Printing

    Back in our mainframe days we made sure to put all the escape seq's that were at print start on the same line as the first print...

    Show the code you use to start the TEXT file and what code you use to eject to a new page in the TEXT file.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Re: Dot Matrix Printing

    Here are the commands that I am using for the EpsonFX emulation:

    VB Code:
    1. ' Determine which escape codes to send printer
    2. ' Initialize the printer and set to Epson FX Emulation
    3. rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(64))
    4. rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(123) & Chr(65))
    5.  
    6. Select Case _CPI
    7.     Case CharactersPerInch.Pica10
    8.         rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(18)) ' Cancel Compressed Print
    9.         rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(80)) ' 10 CPI
    10.     Case CharactersPerInch.Pica12
    11.         rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(18)) ' Cancel Compressed Print
    12.         rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(77)) ' 12 CPI
    13.     Case CharactersPerInch.Pica15
    14.         rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(18)) ' Cancel Compressed Print
    15.         rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(103)) ' 15 CPI
    16.     Case CharactersPerInch.Pica17
    17.         rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(15)) ' Select Compressed Print
    18.         rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(80)) ' 10 CPI
    19.     Case CharactersPerInch.Pica20
    20.         rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(15)) ' Select Compressed Print
    21.         rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(77)) ' 12 CPI
    22. End Select
    23.  
    24. Select Case _PrintQuality
    25.     Case PrintQuality.HSD
    26.         rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(40) & Chr(48)) ' SSD/HSD
    27.     Case PrintQuality.NLQ
    28.         rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(120) & Chr(49)) ' NLQ
    29.         rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(107) & Chr(1)) ' NLQ
    30.     Case PrintQuality.UTL
    31.         rph.SendStringToPrinter(_pDoc.PrinterSettings.PrinterName, Chr(27) & Chr(120) & Chr(0)) ' UTL
    32. End Select

    This is the code I am using for a Form Feed
    VB Code:
    1. PrintLine(FileNumber, Chr(12))


    After much fighting with this printer, I switched over to using IBM ProPrinter emulation and that doesn't seem to cause the creep. No telling what it may break down the road, though. I really hate to change the central printing routine for this app that is in production without a ton of additional testing of the many reports.

    If you see something in that code, let me know.
    My.Settings.Signature = String.Empty

  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Dot Matrix Printing

    The problem you are having is not foreign to me - I remember having issues with EPSON printers...

    At any rate, I look at the HELP for PRINTLINE in .Net and see that in the REMARKS it says that PRINTLINE does include a linefeed, while PRINT does not include a linefeed at the end of the line.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Re: Dot Matrix Printing

    I tried using the PRINT command, but noticed that it didn't write anything into the text file. I wanted to try that to see if it was putting in the extra line feed that was causing the problem.

    On a side note about the PRINTLINE vs PRINT, it would seem to me that if the extra line feed was causing the problem that it would happen on every page, not just the first page like is happening here.
    My.Settings.Signature = String.Empty

  8. #8
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Dot Matrix Printing

    We used to fudge first-page printing for things like tax forms to get around issues like this...

    Do you need to print on the physical first line of the page? It would be a hack, but an easy hack to print an extra blank line on page one to get around this...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    May 2003
    Posts
    758

    Re: Dot Matrix Printing

    I was thinking about doing something similiar. Now that I have the IBM ProPrinter emulation working, I think I am going to step away from this for a while and finish some other modules of this app. Like finish the mechanism to allow for closing the month since it is almost the end of the month.
    My.Settings.Signature = String.Empty

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width