StiHtml5ExportService doesn't render some labels

Stimulsoft Reports.NET discussion
Post Reply
beginner
Posts: 36
Joined: Thu Jun 18, 2015 5:01 am

StiHtml5ExportService doesn't render some labels

Post by beginner »

Hi,

I have one report and I'll use two different services to get PDF and HTML output. `StiPdfExportService` works fine and the result is as expected, but `StiHtml5ExportService` renders slightly different output. The HTML output is missing some labels, and strangely I get the desired result in debug mode, but not when I have published my app.

Please let me know about possible debugging steps, as I'm unable to provide test data.

This is the code that I'm using for HTML output:

Code: Select all

public static string GetHtml(string reportName, Dictionary<string, string> reportParams, HttpResponseBase Response)
        {
            string path = System.Web.Hosting.HostingEnvironment.MapPath(reportPath + reportName + ".mrt");
            StiReport report = new StiReport();
            report.Load(path);

            report.Dictionary.Databases.Clear();
            report.Dictionary.Databases.Add(new StiSqlDatabase(connectionName, connectionString));

            report.Compile();

            foreach (KeyValuePair<string, string> param in reportParams)
            {
                report[param.Key] = param.Value;
            }

            try
            {
                report["userName"] = userName;
                report["repDate"] = DateTime.Now.ToPersianDateAndTimeString();
                report["orgName"] = orgName;
            }
            catch (Exception e) { }

            report.Render(false);
            MemoryStream stream = new MemoryStream();
            StiHtml5ExportService svc = new StiHtml5ExportService() { };

            svc.ExportHtml(report, stream, new StiHtmlExportSettings
            {
                AddPageBreaks = true
            });

            StreamReader reader = new StreamReader(stream);
            stream.Position = 0;
            var html = reader.ReadToEnd();
            html = html
                .Replace("<body", "<body onload='window.print();' ")
                .Replace("<!DOCTYPE html>", "<!DOCTYPE html moznomarginboxes mozdisallowselectionprint>")
                .Replace("</head>", @"<style type=""text/css"" media=""print"">@page { size: auto; margin: 0; }</style></head>");


            Response.Buffer = true;
            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "text/html";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.AddHeader("Content-Length", html.Length.ToString());
            Response.Write(html);
            Response.End();

            return html;
        }
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: StiHtml5ExportService doesn't render some labels

Post by Alex K. »

Hello,

Can you please clarify this issue occurs on all reports or only on some reports.

Thank you.
beginner
Posts: 36
Joined: Thu Jun 18, 2015 5:01 am

Re: StiHtml5ExportService doesn't render some labels

Post by beginner »

It was for a specific report and I recreated those labels and they work as expected.

Thanks for your question Aleksey! ;)
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: StiHtml5ExportService doesn't render some labels

Post by Alex K. »

Hello

We are always glad to help you!
Let us know if you need any additional help.

Thank you.
Post Reply