Hi, I'm triying to create a docx document and save it into memoryStream for not save on server, and after generate a pdf from that memorystream. In mi IIS this code work perfectly but on Azure server no.
Document docpdf = new Document();
using (MemoryStream stream = new MemoryStream())
{
document.SaveToStream(stream, Spire.Doc.FileFormat.Docx);
docpdf.LoadFromStream(stream, Spire.Doc.FileFormat.Docx);
stream.Flush();
stream.Close();
}
using (MemoryStream pdfstream = new MemoryStream())
{
docpdf.SaveToStream(pdfstream, Spire.Doc.FileFormat.PDF);
Response.Clear();
if (Context.Response.IsClientConnected)
{
//Context.Response.AppendHeader("Content-Type:", "application/pdf");
Context.Response.ContentType = "application/pdf";
Context.Response.OutputStream.Write(pdfstream.ToArray(), 0, pdfstream.ToArray().Length);
Context.Response.Flush();
}
pdfstream.Flush();
pdfstream.Close();
}
The error that server is reporting are:
[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) +225161
System.Drawing.Imaging.Metafile..ctor(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) +34
spr1448.0(PageSetup A_0, ImageType A_1, MemoryStream A_2, Int32 A_3, GraphicsUnit A_4) +258
spr1448.0(PageSetup A_0, ImageType A_1, MemoryStream A_2, Int32 A_3) +19
spr1448.20() +224
spr1448.1(IDocument A_0) +235
spr746.0(Document A_0) +93
Spire.Doc.Document.0(Stream A_0) +97
Spire.Doc.Document.SaveToFile(Stream stream, FileFormat fileFormat) +287
Spire.Doc.Document.SaveToStream(Stream stream, FileFormat fileFormat) +47
System.Web.UI.Control.OnLoad(EventArgs e) +95
System.Web.UI.Control.LoadRecursive() +59
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678
If I comment this line: docpdf.SaveToStream(pdfstream, Spire.Doc.FileFormat.PDF); there isn't any problem but the navigator now show pdf visor whit error of document because the memory stream is in .docx format.