MindFusion.Wpf Pack Programmer's Guide
Displaying Reports in a DocumentViewer

In order to display a report in a DocumentViewer it needs to be processed, laid out and rendered to a FixedDocument object. To learn more about these operations, check the Running, Laying Out and Rendering topic. Once the report is rendered in a FixedDocument all that needs to be done is assigning that document to the DocumentViewer's Document property.

The following code illustrates all necessary steps. The code assumes that report and viewer are variables identifying existing Report and DocumentViewer objects respectively.

C#  Copy Code

report.Run();

ReportLayout layout = report.Layout(
    new Size(8.5 * 96, 11 * 96), new Thickness(0.5 * 96),
    MindFusion.Reporting.PageOrientation.Portrait);

FixedDocumentRenderTarget renderTarget = new FixedDocumentRenderTarget();
layout.RenderAllPages(renderTarget);

viewer.Document = renderTarget.Document;

Visual Basic  Copy Code

report.Run()

Dim layout = report.Layout( _
    New Size(8.5 * 96, 11 * 96), New Thickness(0.5 * 96), _
    MindFusion.Reporting.PageOrientation.Portrait)

Dim renderTarget = New FixedDocumentRenderTarget()
layout.RenderAllPages(renderTarget)

viewer.Document = renderTarget.Document