Skip to content

Instantly share code, notes, and snippets.

@arman-hpp
Created December 5, 2016 17:42
Show Gist options
  • Save arman-hpp/b6bc8f48b5e518abd806c1e28597899c to your computer and use it in GitHub Desktop.
Save arman-hpp/b6bc8f48b5e518abd806c1e28597899c to your computer and use it in GitHub Desktop.
Print Stimulsoft Report As PDF With Telerik
var report = new StiReport();
report.Load((byte[])Resources.ResourceManager.GetObject("TestReport"));
var reportBusinessObjects = new List<ReportBusinessObject>
{
new ReportBusinessObject("", "TestReport", reportDto)
};
LoadBusinessObjects(report, reportBusinessObjects);
report.Compile();
report.Render(false);
var reportMemoryStream = new MemoryStream();
report.ExportDocument(StiExportFormat.Pdf, reportMemoryStream);
var pdfElement = new RadPdfViewerElement();
pdfElement.LoadDocument(reportMemoryStream);
var printDocument = new RadPrintDocument
{
AssociatedObject = pdfElement,
PrintController = new StandardPrintController() //disable printing window
};
pdfElement.DocumentLoaded += (sender, args) =>
{
printDocument.Print();
reportMemoryStream.Dispose();
pdfElement.Dispose();
printDocument.Dispose();
report.Dispose();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment