C1ReportViewer Task-Based Help > Loading Documents into C1ReportViewer |
If you run the application after adding a C1ReportViewer control to your application, you'll see an empty C1ReportViewer on the page. The next step is to invoke the LoadDocument method to add some content to the control. The LoadDocument method allows you to load content from Stream objects (which may contain PDF, HTML, or MHTML documents), or from strings (which may contain HTML or MHTML documents).
You can easily load a document from an application resource. For example, complete the following steps:
Visual Basic |
Copy Code
|
---|---|
Imports C1.WPF.ReportViewer
|
C# |
Copy Code
|
---|---|
using C1.WPF.ReportViewer;
|
Visual Basic |
Copy Code
|
---|---|
Public Sub New() InitializeComponent() Dim resource = Application.GetResourceStream(New Uri("AppName;component/resource.pdf", UriKind.Relative)) Me.C1ReportViewer1.LoadDocument(resource.Stream) End Sub |
C# |
Copy Code
|
---|---|
public MainPage() { InitializeComponent(); var uri = new Uri("/AppName;component/resource.pdf", UriKind.Relative); var resource = Application.GetResourceStream(uri); this.C1ReportViewer1.LoadDocument(resource.Stream); } |
This code adds a stream and loads the stream into the C1ReportViewer control. Note that if you named the application differently, you will need to replace "AppName" with the name of your project. If you added a different PDF file, replace "resource.pdf" with the name of your file.