This example shows how to export a report to the PDF format from code. You need to create the report object of the StiReport type, then load the report template file by calling the loadFile() method. After this, you should render the report by calling the renderAsync() method of the report object:
// Create a new report instance
var report = new Stimulsoft.Report.StiReport();
// Load report from url
// Render report

For exporting the report to the PDF format you should create two objects of the StiPdfExportSettings and StiPdfExportService classes. First object defines all export settings, the second object is a PDF export service. Also you need to create the MemoryStream object, it is needed to output the result of the export.

To start the export, simply invoke the exportTo() method of the export service object, which accepts the rendered report, memory stream and export settings. For example, the result is saved to the file using the Object.saveAs() method. This method was added in the Stimulsoft library, you can use it for saving files:
function saveReportPdf() {
	// Create an PDF settings instance. You can change export settings.
	var settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
	// Create an PDF service instance.
	var service = new Stimulsoft.Report.Export.StiPdfExportService();
	// Create a MemoryStream object.
	var stream = new Stimulsoft.System.IO.MemoryStream();
	// Export PDF using MemoryStream.
	service.exportTo(report, stream, settings);
	// Get PDF data from MemoryStream object
	var data = stream.toArray();
	// Get report file name
	var fileName = String.isNullOrEmpty(report.reportAlias) ? report.reportName : report.reportAlias;
	// Save data to file
	Object.saveAs(data, fileName + ".pdf", "application/pdf");

In the screenshot below you can see the result of the sample code:

Export Report to PDF