I was trying to fetch a word from different sources via url/shared link/shared drives and save it to memory stream. My memory stream gets the data everytime but while converting it to PDF via Spire.Doc it gives an error saying "A generic error occurred in GDI+". But this happens only in my production not in localhost. The app is hosted in Azure cloud.

I put few logs and got to know that line number 3 is causing the issue.

fileContentStream and finalStream are the memory streams.

The code which I used is:

Spire.Doc.Document spireDoc = new Spire.Doc.Document();
spireDoc.LoadFromStream(fileContentStream, Spire.Doc.FileFormat.Auto);
spireDoc.SaveToStream(finalStream, Spire.Doc.FileFormat.PDF);
1

There are 1 best solutions below

0
On BEST ANSWER

To convert Word to PDF on Azure cloud using Spire.Doc, you need to use the below code:

Document document = new Document();
spireDoc.LoadFromStream(stream);
ToPdfParameterList tpl = new ToPdfParameterList
{
    UsePSCoversion = true
};
document.SaveToStream(stream, tpl);