.NET C# PrintDocument is very slow with Dot Matrix Printer

1.1k Views Asked by At

I have a problem with my c# application, because i need to print with dot matrix printer "Olivetti PR2 Plus" using X and Y Position coordinates, like VB6 did. the problem is if the string have more than 20 characters aprox, the printer is very slow and i need to print fast.

I have the following code for testing purposes and have the problem.

private void btnPrint_Click(object sender, EventArgs e)
    {
        Document = new PrintDocument();            
        Document.PrintPage += Document_PrintPage;
        Document.PrinterSettings.PrinterName = ((ICollection)PrinterSettings.InstalledPrinters).OfType<string>().Where(p => p.ToUpper().Contains("OLIVETTI")).First().ToString();        
        Document.Print();
    }

private void Document_PrintPage(object sender, PrintPageEventArgs e)
        {
            e.Graphics.DrawString("asdfasdfasdfasdasdffasdfasdfasdf", new Font("Consolas", 8), Brushes.Black, 20, 0, new StringFormat());
            e.Graphics.DrawString("asdfasdfasdasdaasdfsdfffasdfasdf", new Font("Consolas", 8), Brushes.Black, 20, 10, new StringFormat());
            e.Graphics.DrawString("asdfasdfaasdfsasdfsadfdfasdfasdf", new Font("Consolas", 8), Brushes.Black, 20, 20, new StringFormat());
            e.Graphics.DrawString("asfdasdfsadfasasdfasdfdasdfasdff", new Font("Consolas", 8), Brushes.Black, 20, 30, new StringFormat());
            e.Graphics.DrawString("asfdasdsdafasadfsasdfdasdfasdfff", new Font("Consolas", 8), Brushes.Black, 20, 40, new StringFormat());
            e.Graphics.DrawString("asdfaasdsadfsadffsadfsdassadfdff", new Font("Consolas", 8), Brushes.Black, 20, 50, new StringFormat());
            e.Graphics.DrawString("asfdasdfsdafsadfsadfasasasdfdfdf", new Font("Consolas", 8), Brushes.Black, 20, 60, new StringFormat());
            e.Graphics.DrawString("asdfasadfassadfdfssadfassadfdfdf", new Font("Consolas", 8), Brushes.Black, 20, 70, new StringFormat());
            e.Graphics.DrawString("asfdasadfasadfsdfssadasasdffdfdf", new Font("Consolas", 8), Brushes.Black, 20, 80, new StringFormat());   
        }

I can't print in RAW "DOS" mode because the source of the data to print have specific coordinates for match with the paper formats. ¿any sugestion to improve the perfomance of the printer?

0

There are 0 best solutions below