Page 1 of 1

Export to MemoryStream problem

Posted: Thu Jun 08, 2017 11:23 am
by mehdi63
Hi
could u please help me to export document to memorystream in asp.net mvc.
it cant export to MemoryStream but export directly to file or pdf is ok. :(

Code: Select all

         
   report.ExportDocument(StiExportFormat.ImageJpeg, stream, es);

Code: Select all

private MemoryStream report()
        {
//log section
            Stimulsoft.Report.StiLogService.LogEnabled = true;
            StiLogService service1 = StiConfig.Services.GetService(typeof(StiLogService)) as StiLogService;
            service1.LogPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Content/Reports/Report.log"); // Path and filename


//read report section
            StiReport report = new StiReport();
            DataSet data = new DataSet();
            report.Load(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/Reports/TwoSimpleLists.mrt"));
            data.ReadXml(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/Data/Demo.xml"));
            report.RegData(data);


//memorystream and render report section
           
            MemoryStream stream = new System.IO.MemoryStream();
           
            report.Render();


            //ExportSetting and export section

            StiJpegExportSettings es = new StiJpegExportSettings();
            es.PageRange = new StiPagesRange(1);

            report.ExportDocument(StiExportFormat.ImageJpeg, stream, es);

           //Write memorystream to file which result is empty file 
            using (var fileStream = new FileStream(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/Reports/abaw.bmp"), FileMode.Create, FileAccess.Write))
            {
                stream.CopyTo(fileStream);
            }


            return stream;
        }

Re: Export to MemoryStream problem

Posted: Fri Jun 09, 2017 9:32 am
by Alex K.
Hello,

Please send us a simple project which reproduces the issue for analysis.

Thank you.

Re: Export to MemoryStream problem

Posted: Fri Jun 09, 2017 11:29 am
by mehdi63
Hello
I changed it.
Thank you

Re: Export to MemoryStream problem

Posted: Fri Jun 09, 2017 12:40 pm
by Alex K.
Hello

Ok.
Please let us know if you need any additional help.

Thank you.

Re: Export to MemoryStream problem

Posted: Fri Jun 09, 2017 12:58 pm
by mehdi63
Hello
unfortunately The problem exist .
I reduced the sample code in first section.
please help to solve the problem.
tnx

Re: Export to MemoryStream problem

Posted: Mon Jun 12, 2017 6:44 pm
by Ivan
Hello,

Please instead of stream.CopyTo() method use the stream.WriteTo() method.

Thank you.