none
Printing speed is low while using System.Drawing.Printing.PrintDocument RRS feed

  • Question

  • Hi Team,

    In our application, we perform metafile (vector) printing using System.Drawing.Printing.PrintDocument and found that the printing speed is very slow for most of the physical printers.

    Since we have used high end printers which usually prints the files in high speed, we performed the Bitmap (scalar) image printing by print the general images (Size around 80kb to 120kb) from the disk using System.Drawing.Printing.PrintDocument and found that also took more time. So, we suspect that this issue related to System.Drawing.Printing.PrintDocument.

    Please find list of physical printers we used,

    1. Konica Minolta C458
    2. Konica Minolta C308
    3. Konica Minolta C654e
    4. HP Laserjet 5200 printer

    Code snippet we used,

    static int m_printIndex = 0;

    static string[] files;

    static void Main(string[] args)

    {

          // 10 images in files

          files = Directory.GetFiles(@"../../Images/");

         

          System.Drawing.Printing.PrintDocument docToPrint = new System.Drawing.Printing.PrintDocument();

         

          docToPrint.PrintPage += DocToPrint_PrintPage;

          docToPrint.Print();

    }

    private static void DocToPrint_PrintPage(object sender, PrintPageEventArgs e)

    {

           Bitmap bitmap = new Bitmap(files[m_printIndex]);

           e.Graphics.DrawImage(bitmap, e.PageBounds);

           m_printIndex++;

           e.HasMorePages = m_printIndex < files.Length;

    }

    Can you please let us know is there any options to be enabled for improving the printing speed using System.Drawing.Printing.PrintDocument?

     

    Also, kindly suggest us any alternate way to improve the speed and also supports vector printing using System apart from the System.Drawing.Printing if it’s the behavior.

    Note: The printing speed is fast when printing the images in Microsoft Print to PDF and One Note.

    Regards,

    Uthandaraja S

    Friday, August 23, 2019 1:45 PM

All replies

  • Hi,

    Maybe you can try multithreading, perform a print operation in a new thread.

    Besides, you can also refer to the third-party control Printing-Exporting.

    Regards,

    Kyle

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 26, 2019 3:24 AM
    Moderator
  • Hi Kyle,

    Thanks for your response.

    Since we are not about to use any third party tool, in our environment, we would like to find any solution supported by System.

    Regarding “Maybe you can try multithreading, perform a print operation in a new thread.

    Can you please share any code example to perform print operation using multithreading which will be helpful for us to analyze further on this?

    Regards,

    Uthandaraja S

    Monday, August 26, 2019 11:32 AM
  • Hi,

    You can use "Thread" to achieve multithreading. Jsut like the followed.

        private void button1_Click(object sender, EventArgs e)
        {
            Thread thread1 = new Thread(new ParameterizedThreadStart(PrintMethod));
            thread1.Start();
        }
    
        private void PrintMethod()
        {
            // Code omitted
        }

    Or use control "BackgroundWorker".

        private void button2_Click(object sender, EventArgs e)
        {
            using (BackgroundWorker bw = new BackgroundWorker())
            {
                bw.DoWork += new DoWorkEventHandler(bw_DoWork);
                bw.RunWorkerAsync();
            }
        }
    
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            // ...Code omitted
        }

    Hope these can help you.

    Regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, August 27, 2019 2:46 AM
    Moderator