Show Rendered Document in the Viewer

This example shows how to show the rendered report document in the viewer. For creating and showing the viewer from code you will need to call the StiViewerFx.initialize() static method. Call this method in the initialize event of the application:

<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
minWidth="1024" minHeight="768" backgroundColor="#e8e8e8"
initialize="onInitialize()" xmlns:viewer="stimulsoft.viewer.*">

...

private function onInitialize(): void
{
StiViewerFx.initialize();

...
}


To show the report in the viewer you need to load a rendered report file, for example assign it to the documentString variable. Next you need to create the StiReport object and load the rendered report from this string variable using the loadDocumentFromString() method. After these actions done, you can show the report in the viewer using the show() method:

private function onViewDocumentClick(): void
{
// Create new report object
var report: StiReport = new StiReport();
// Load document from XML string
report.loadDocumentFromString(documentString);
// Show report in Viewer
report.show();
}


Also you can show the report in the viewer as a dialog window. Simply change the show() method on the showDialog() method, all other actions are the same:

private function onViewInDialogWindowClick(): void
{
// Create new report object
var report: StiReport = new StiReport();
// Load document from XML string
report.loadDocumentFromString(documentString);
// Show report in Viewer dialog window
report.showDialog();
}


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

Show Rendered Document in the Viewer