Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Feb 06, 2018 10:37 am

Hi guys!,

I'm getting A generic error occurred in GDI+ error when I try to execute the followin code:

Code: Select all
                               

                                stream = new MemoryStream(c.MTDGenerarPdfAnatomia(ref error, userid, idtest));
                                MemoryStream streamPDF = new MemoryStream();

                                doc.LoadFromStream(stream, FileFormat.Docx);

                                ToPdfParameterList tpl = new ToPdfParameterList
                                {
                                   UsePSCoversion = true//azure
                                };
                                doc.SaveToStream(streamPDF, tpl); // error on this line.
                                result = stream.ToArray();


I have tried to execute without this line (doc.SaveToStream) and it works perfect, the error doesn't throw.
I had the same error on the past and I solved it with a service which return a pdfStream and I didn't need use the Save function because I made this

Code: Select all
                                   doc.LoadFromStream(streamPDF, FileFormat.PDF);
                                    Response.Clear();
                                    Response.ContentType = "application/pdf";
                                    Response.OutputStream.Write(streamPDF.ToArray(), 0, streamPDF.ToArray().Length);
                                    Response.Flush();
                                    Response.Close();
                                    streamPDF.Flush();
                                    streamPDF.Close();


However I have to use the Save Function now, I have a WCF service which return a byte[] (docx extesion) and it works fine.
In my local server run fine too (with my IIS), but when I deploy the proyect on Azure, I revice the GDI+ error.

How can I solve this situation?

Best regards!

juankaw89@gmail.com
 
Posts: 15
Joined: Wed Aug 24, 2016 7:10 am

Wed Feb 07, 2018 3:14 am

Hi,

Thanks for your inquiry.
If you were using an older version, please first upgrade to our latest Spire.Doc(Spire.Doc Pack(hot fix) Version:6.2.0) to have a try. If the issue still exists in this version, please provide your input Docx file with us for further investigation (you could send it to us via email support@e-iceblue.com).

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Fri Feb 09, 2018 8:35 am

Hi,

Greetings from E-iceblue.
Did you test the latest hotfix? If the issue still happens, please provide your input Docx file with us. We will look into it and help you out.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Mon Feb 12, 2018 8:53 am

Hi,

Sorry for delay, yes, the problem was solved, than for you assistance,

Best Regards

juankaw89@gmail.com
 
Posts: 15
Joined: Wed Aug 24, 2016 7:10 am

Mon Feb 12, 2018 9:00 am

Hi,

Thanks for your feedback.
Please feel free to contact us if you have any question.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Fri Sep 14, 2018 3:48 pm

Hi,

I am getting similar issue with the latest Spire.Doc version 6.8.16.
Error: A generic error occurred in GDI+.

Can you please provide me your assistance on this issue?

I am getting issue right at below line of code.

document.SaveToStream(memorystream, Spire.Doc.FileFormat.PDF);

Thank you,
Andy

dev.communications
 
Posts: 6
Joined: Wed Sep 05, 2018 2:25 pm

Mon Sep 17, 2018 1:36 am

Hello,

Thanks for your inquiry and sorry for late reply as weekend.
Please use below code to convert word to PDF on Azure server. If the issue still happens after trying, please provide your word file to help us further investigate your issue. You could send it to us via email (support@e-iceblue.com).
Code: Select all
Document document = new Document();
document.LoadFromFile(wordFile);
ToPdfParameterList tpl = new ToPdfParameterList
{
    UsePSCoversion = true//azure
};
document.SaveToStream(memorystream, tpl);

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Thu Feb 10, 2022 1:09 pm

Hi there, we have this error as well with Azure WebApp

Spire.Doc Ver: 9.10.0

Error log:
[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Imaging.Metafile..ctor(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, String description) +231
System.Drawing.Imaging.Metafile..ctor(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) +44
sprᫀ.ᜀ(PageSetup A_0, ImageType A_1, MemoryStream A_2, Int32 A_3, GraphicsUnit A_4) +258
sprᫀ.ᜀ(PageSetup A_0, ImageType A_1, MemoryStream A_2, Int32 A_3) +19
sprᫀ.ᜒ() +250
sprᫀ.ᜁ(IDocument A_0) +287
spr⊎.ᜀ(Document A_0) +106
spr⊎.ᜀ(Document A_0, ToPdfParameterList A_1) +69
Spire.Doc.Document.ᜀ(Stream A_0, ToPdfParameterList A_1) +276
Spire.Doc.Document.SaveToStream(Stream stream, ToPdfParameterList paramList) +47

We tried the fix suggested (below) but the error still persist:
ToPdfParameterList tpl = new ToPdfParameterList
{
UsePSCoversion = true//azure
};
document.SaveToStream(responseStream.OutputStream, tpl);

inheritaustralia
 
Posts: 5
Joined: Wed Nov 24, 2021 6:25 am

Fri Feb 11, 2022 2:10 am

Hello inheritaustralia,

Thanks for your inquiry.
Since you are using an older version, please upgrade to our last Spire.Doc(Spire.Doc Pack Version:10.1) to test it again. If the issue still exists in this version, please provide your sample Word file and your application type(such as WebApp .NET Core3.1 )for further investigation.You could attach them here or send them to us via email (support@e-iceblue.com). Thanks in advance.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.Doc