Free Support Forum - aspose.com

GDI+ Exception

Hi,

When I invoke the PageCount property on the Document object which has the attached Word document loaded, I get the following exception.

2009-11-17 09:38:46:574 ERROR AsposeDoc2Doc#run - System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
at System.Drawing.Graphics.MeasureString(String text, Font font, SizeF layoutArea, StringFormat stringFormat)
at System.Drawing.Graphics.MeasureString(String text, Font font, Int32 width, StringFormat format)
at ?.?.?(String ?, Font ?)
at ?.?.get_?()
at ?.?.get_?()
at ?.?.?(? ?)
at ?.?.?(? ?)
at ?.?.?()
at ?.?.?(Int32 ?)
at ?.?.?(Int32 ?)
at ?.?.?()
at ?.?.?()
at ?.?.?(? ?)
at ?.?.?(? ?, ? ?)
at ?.?.?(? ?)
at ?.?.?()
at ?.?.?()
at ?.?.?(Document ?, ? ?)
at Aspose.Words.Document.get_PageCount()
at offline.AsposeDoc2Doc.run()

I am using Aspose.Words version 7.0.0. I have found some old posts talking about setting the SaveOptions.ExportImagesFolder property to solve this problem, but that property seems to have been obsoleted now.

Any help would be appreciated.

Thanks,

Hi

Thanks for your inquiry. I cannot reproduce the problem using the latest version of Aspose.Words (8.0.0). You can download this version from here:
http://www.aspose.com/community/files/51/file-format-components/aspose.words-for-.net-and-java/category1188.aspx
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Best regards,

Hi Andrey,

Upgrading to version 8.0.0 fixed the problem in the first document I attached, but I now get the same error when trying to convert the attached WordML document to PDF. I also did a bit more testing and found that version 6.3.0 of Words .net was the last version which successfully converted and / or saved both documents I have attached to this issue as both pdf and doc files.

Also, the server environment that the Aspose component is running on is Windows Server 2003 64 bit service pack 2, using .net2.0 sp1.

The error I receive on this doc is

2009-11-20 10:34:43:906 ERROR WordML2Pdf#run - System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
at System.Drawing.Graphics.MeasureString(String text, Font font, SizeF layoutArea, StringFormat stringFormat)
at System.Drawing.Graphics.MeasureString(String text, Font font, Int32 width, StringFormat format)
at ?.?.?(String ?, Font ?)
at ?.?.get_?()
at ?.?.get_?()
at ?.?.?(? ?)
at ?.?.?(? ?)
at ?.?.?()
at ?.?.?(Int32 ?)
at ?.?.?(Int32 ?)
at ?.?.?()
at ?.?.?()
at ?.?.?(? ?)
at ?.?.?(? ?, ? ?)
at ?.?.?(? ?)
at ?.?.?()
at ?.?.?()
at ?.?.?(Document ?, ? ?)
at Aspose.Words.Document.get_?()
at Aspose.Words.Document.?(Stream ?, String ?, SaveFormat ?)
at Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat)
at offline.WordML2Pdf.run()
Thanks,

Stu

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Sorry for delayed answer. I need more time for testing. I tried with SP 1 and cannot reproduce the problem. I’ll try to install SP 2 ant let you know how it goes on my side. Please expect replay in few hours.

Best regards,

Hi;

I have the exact same error here, the same code runs ok on two machines, but it fails on two others. The only difference is that in the ones it runs the SO is windows 2008 32 bits, the failing ones are Windows 2003 64 bits. The app is running under asp.net with integrated windows authentication. Any explanation?

Looking forward for an answer :)

Mauricio Sougarret

Hey Mauricio,

I haven’t heard back from Aspose on this, but I did manage to figure out what is causing the exception on my end. The documents that I am generating all have a table in the footer. I am then wrapping the table in a bookmark. The cause of the GDI+ exception for me is directly linked to where the BookmarkStart is placed with regards to the table.

I had been putting the BookmarkStart in the first paragraph of the first cell in the first row of the table. When I render the table this way and then try and save the document as a PDF, I get the GDI+ exception. However, if I put an empty paragraph ahead of the table (i.e as the table’s previous sibling) in the footer and put the BookmarkStart in it, converting the document to PDF, calling pageCount, etc all work on the doc. In each case the BookmarkEnd is always in the last paragraph of the last cell in the last row of the table.

I don’t know if this will directly apply to you, but hopefully it will help. Also, on my 32bit Windows 2003 server machine both ways work fine, I never get the GDI+ exception. It only appears for me on the 64 bit Win2003 server box.

Stu

Hello Mauricio,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Could you please attach your document here for testing? I will check the problem on my side and provide you more information.

Stu, I cannot reproduce the problem with your document on my side.

Best regards,

Hi, i attach the word document and i hope that you can reproduce the problem.

Best regards,

Hi

Thanks for your inquiry. I cannot reproduce the problem using the latest version of Aspose.Words (8.1.0). I can successfully convert this document to PDF on Windows 2003 x64.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Best regards,