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!