Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Sep 29, 2015 7:50 am

Hi,
I am using free spire.pdf v3.2.52.56040 to print existing pdf documents.
It prints about 1900+ documents and crashes with the either of the following message:
Handle is invalid or A generic error occurred in GDI+.

Here is the code that i am using.
Code: Select all
PdfDocument doc = new PdfDocument();
try
            {
               doc.LoadFromFile(PrintFilePath);
               doc.PrinterName = printer;
               bool canDuplex = doc.PrintDocument.PrinterSettings.CanDuplex;

                if (canDuplex)
                {
                    doc.PrintDocument.PrinterSettings.Duplex = Duplex.Vertical;
                }

                if (doc.PrintDocument.PrinterSettings.IsValid)
                {
                   
                    doc.PrintDocument.Print();
                 }
        else
                {
                    throw new Exception(printer + " : Invalid Printer or Printer Settings");                   
                }
            }
            catch (Exception ex)
            {
                  throw new Exception(printer + " :" + ex.Message);
            }
            finally
            {
                doc.PrintDocument.Dispose();
                doc.Close();
                doc.Dispose();               
            }

svha
 
Posts: 5
Joined: Mon Sep 28, 2015 11:49 pm

Tue Sep 29, 2015 8:28 am

Hello,

Thanks for your inquiry.
Please test the latest version, Spire.PDF Pack(Hot Fix) Version:3.5.51(http://www.e-iceblue.com/Download/downl ... t-now.html), if you still have the issue, please send us the documents which crashed the error to help us reproduce it.
Thank you.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Wed Sep 30, 2015 6:10 am

Hi Amy,
Thank you for your prompt reply.
I am still getting the same issue. It prints 1950 documents and then crashes.
I have tried printing the same document over and over again and it fails after 1900-1950 iterations.

Here is the full stack of the error message.
Due to the sensitive nature of the documents we print I will not able to upload it, but the same document prints 1900 times and the fails. It seems like it is not closing the handle properly
Code: Select all

A generic error occurred in GDI+

   at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
   at System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
   at System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, PointF point, StringFormat format)
   at sprᲆ.ᜀ(Graphics A_0, spr᫋ A_1, Boolean A_2)
   at sprᲆ.ᜁ(Graphics A_0, spr᫋ A_1, Boolean A_2)
   at spr᫋.ᜀ(String A_0, sprᮌ A_1, String A_2, Boolean A_3)
   at spr᫋.ᜀ(String[] A_0, String A_1)
   at spr᫋.ᜀ(sprᰢ A_0)
   at spr᫋.ᜆ(Boolean A_0)
   at spr᫋.ᜠ()
   at Spire.Pdf.PdfDocument.ᜀ(Object A_0)
   at Spire.Pdf.PdfDocument.OnPrintPage(Object sender, PrintPageEventArgs e)
   at System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document)
   at System.Drawing.Printing.PrintController.Print(PrintDocument document)
   at System.Drawing.Printing.PrintDocument.Print()



Thank you

svha
 
Posts: 5
Joined: Mon Sep 28, 2015 11:49 pm

Wed Sep 30, 2015 6:41 am

Hello,

Thanks for your further information.
I have posted your issue to our dev team. We will inform you when there is any update.
Welcome to write to us again for further problems.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Thu Oct 08, 2015 4:42 am

Hi Amy,
Do you have any update on this.

Thank you

Regards

svha
 
Posts: 5
Joined: Mon Sep 28, 2015 11:49 pm

Thu Oct 08, 2015 8:30 am

Hi,

Sorry for the delay update because we just finished a holiday(01/10/2015 - 07/10/2015 (GMT+8)) come back. We tried printing a simple document 2000 times but didn't reproduce your issue.
To help us resolve it, please send us a document without security data which can reproduce your issue,and tell us your system environment, for example:
Windows 7 Enterprise Edition SP1 x64
Regional and Language Options

Please send them to amy.zhao@e-iceblue.com or support@e-iceblue.com.

Thank you.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Fri Oct 09, 2015 6:17 am

Hi Amy,
have attached the document with exception stack trace.

Code: Select all
   at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
   at System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format)
   at System.Drawing.Graphics.DrawString(String s, Font font, Brush brush, PointF point, StringFormat format)
   at sprᲆ.ᜀ(Graphics A_0, spr᫋ A_1, Boolean A_2)
   at sprᲆ.ᜁ(Graphics A_0, spr᫋ A_1, Boolean A_2)
   at spr᫋.ᜀ(String A_0, sprᮌ A_1, String A_2, Boolean A_3)
   at spr᫋.ᜀ(String[] A_0, String A_1)
   at spr᫋.ᜀ(sprᰢ A_0)
   at spr᫋.ᜆ(Boolean A_0)
   at spr᫋.ᜠ()
   at Spire.Pdf.PdfDocument.ᜀ(Object A_0)
   at Spire.Pdf.PdfDocument.OnPrintPage(Object sender, PrintPageEventArgs e)
   at System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document)
   at System.Drawing.Printing.PrintController.Print(PrintDocument document)
   at System.Drawing.Printing.PrintDocument.Print()


Thanks
Last edited by svha on Fri Nov 13, 2015 2:53 am, edited 1 time in total.

svha
 
Posts: 5
Joined: Mon Sep 28, 2015 11:49 pm

Fri Oct 09, 2015 7:05 am

Hi,

Thanks for providing.
I have posted it to our dev team. We will tell you when it is resolved.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Mon Oct 12, 2015 3:49 am

Hi,

We have tested your document using the below code but still didn't reproduce your issue. It printed all files without any errors.
Testing code:
Code: Select all
    for (int i = 0; i < 2000; i++)
            {
                PdfDocument doc = new PdfDocument();
                try
                {
                    doc.LoadFromFile("..\\..\\document_test.pdf");
                    doc.PrintDocument.PrintController = new StandardPrintController();
                    string filename = string.Format("..\\..\\output\\{0}.xps", i);
                    doc.PrintDocument.PrinterSettings.PrintFileName = filename;
                    doc.PrintDocument.PrinterSettings.PrintToFile = true;

                    bool canDuplex = doc.PrintDocument.PrinterSettings.CanDuplex;

                    if (canDuplex)
                    {
                        doc.PrintDocument.PrinterSettings.Duplex = Duplex.Vertical;
                    }

                    if (doc.PrintDocument.PrinterSettings.IsValid)
                    {

                        doc.PrintDocument.Print();
                    }
                    else
                    {
                        throw new Exception("Invalid Printer or Printer Settings");
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
                finally
                {
                    doc.PrintDocument.Dispose();
                    doc.Close();
                    doc.Dispose();
                }
            }

Is your code for loop 2000 times in the same way with me? If not, please share your code, and also please tell us your system environment and printer name.

Thanks.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Tue Nov 03, 2015 3:38 am

Hi,

Would you please give us a reply at your convenience as soon as possible?

Thank you.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Wed Nov 04, 2015 1:11 pm

Hi Amy,

The amentioned hotfix, is it also for the free Spire.Pdf version?
And would it also solve the landscape bug mentioned in t5502 ?
(landscape-setting which doesn't work in the free version)

Thx
Chris

swiftchon
 
Posts: 3
Joined: Thu Oct 22, 2015 8:07 pm

Thu Nov 05, 2015 2:28 am

Hi Chris,

Thanks for your inquiry.
The hotfix also solved the landscape bug. It is commercial version.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Thu Nov 05, 2015 7:27 am

Hi Amy,

Ok Thx. Just asking because the user "svha" who initiated this ticket, also states in his initial post that he's using the free version.
That's why it wasn't clear for me.
Thx
Chris

swiftchon
 
Posts: 3
Joined: Thu Oct 22, 2015 8:07 pm

Thu Nov 05, 2015 8:10 am

Hi Chris,

Sorry, Free version updates very slowly due to other priority issues. The issues happen in the free version, all fixes first will be included in the commercial version. We will add the fixes to Free version when we have enough time. So once the issues are resolved, we first inform customer commercial version. The package(Spire.PDF Pack(Hot Fix) Version:3.5.51) which was told to svha is also commercial version.

Hope above information help you. Please feel free to write to us again if you have further problems.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2772
Joined: Wed Jun 27, 2012 8:50 am

Mon Nov 09, 2015 6:20 am

Hi Amy,
Sorry for the delayed response was away.
When i put it in a loop like the way you did it works, but in an application it fails after printing about 1980 documents.
The pdf files are generated by Reporting Services and the application picks it up from a watched folder and prints it.
I used a batch file to copy pdf files to the watched folder and it crashed after printing 1980+ files.
The exception thrown was "The Handle is Invalid" and " The Operation Completed Successfully".

Thank you

Regards

svha
 
Posts: 5
Joined: Mon Sep 28, 2015 11:49 pm

Return to Spire.PDF