Export to MemoryStream problem

Stimulsoft Reports.WEB discussion
Post Reply
mehdi63
Posts: 3
Joined: Thu Jun 08, 2017 11:06 am

Export to MemoryStream problem

Post 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;
        }
Last edited by mehdi63 on Fri Jun 09, 2017 11:28 am, edited 6 times in total.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Export to MemoryStream problem

Post by Alex K. »

Hello,

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

Thank you.
mehdi63
Posts: 3
Joined: Thu Jun 08, 2017 11:06 am

Re: Export to MemoryStream problem

Post by mehdi63 »

Hello
I changed it.
Thank you
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Export to MemoryStream problem

Post by Alex K. »

Hello

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

Thank you.
mehdi63
Posts: 3
Joined: Thu Jun 08, 2017 11:06 am

Re: Export to MemoryStream problem

Post by mehdi63 »

Hello
unfortunately The problem exist .
I reduced the sample code in first section.
please help to solve the problem.
tnx
Attachments
WindowsFormsApplication2.rar
(27.27 KiB) Downloaded 220 times
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Re: Export to MemoryStream problem

Post by Ivan »

Hello,

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

Thank you.
Post Reply