I'm using Stimulsoft in ASP.NET MVC 5 and I like to show print dialog to the user.
On the client side I only have an `id` and report is not loaded. I'd like to either show directly print dialog or show `print preview` to the user.
Please guide me with this requirement.
Print Directly for the client
Re: Print Directly for the client
Hello,
Please try to use the MVCViewer for the showing report in which present several print dialog option.
Thank you.
Please try to use the MVCViewer for the showing report in which present several print dialog option.
Thank you.
Re: Print Directly for the client
Hi Aleksey,
I don't want to show him a report, a print preview in another window maybe, but not a full viewer for sure.
Thanks for your replay.
I don't want to show him a report, a print preview in another window maybe, but not a full viewer for sure.
Thanks for your replay.
Re: Print Directly for the client
Hello,
Please try to use the export to in HTML or PDF and print.
For example:
Thank you.
Please try to use the export to in HTML or PDF and print.
For example:
Code: Select all
public ActionResult PrintHTML()
{
StiReport report = new StiReport();
report.Load("D:\\MyReport.mrt");
report.Render(false);
MemoryStream stream = new MemoryStream();
StiHtmlExportSettings settings = new StiHtmlExportSettings();
settings.AddPageBreaks = true;
StiHtmlExportService service = new StiHtmlExportService();
service.ExportHtml(report, stream, settings);
StreamReader reader = new StreamReader(stream);
stream.Position = 0;
string html = reader.ReadToEnd();
html = html.Replace("<body>", "<body onload='window.print();'>");
this.Response.Buffer = true;
this.Response.ClearContent();
this.Response.ClearHeaders();
this.Response.ContentType = "text/html";
//this.Response.AddHeader("Content-Disposition", "attachment; filename=\"report.html\"");
this.Response.ContentEncoding = Encoding.UTF8;
this.Response.AddHeader("Content-Length", html.Length.ToString());
this.Response.Write(html);
this.Response.End();
return View();
}
public ActionResult PrintPDF()
{
StiReport report = new StiReport();
report.Load("D:\\MyReport.mrt");
report.Render(false);
MemoryStream stream = new MemoryStream();
StiPdfExportSettings settings = new StiPdfExportSettings();
settings.AutoPrintMode = StiPdfAutoPrintMode.Dialog;
StiPdfExportService service = new StiPdfExportService();
service.ExportPdf(report, stream, settings);
this.Response.Buffer = true;
this.Response.ClearContent();
this.Response.ClearHeaders();
this.Response.ContentType = "application/pdf";
//this.Response.AddHeader("Content-Disposition", "attachment; filename=\"report.pdf\"");
this.Response.ContentEncoding = Encoding.UTF8;
this.Response.AddHeader("Content-Length", stream.Length.ToString());
this.Response.BinaryWrite(stream.ToArray());
this.Response.End();
return View();
}