# Loading Documents into C1ReportViewer

## Content



If you run the application after adding a [C1ReportViewer](/componentone/api/wpf/online-reportviewer/dotnet-framework-api/C1.WPF.ReportViewer.4.6.2/C1.WPF.ReportViewer.C1ReportViewer.html) control to your application, you'll see an empty [C1ReportViewer](/componentone/api/wpf/online-reportviewer/dotnet-framework-api/C1.WPF.ReportViewer.4.6.2/C1.WPF.ReportViewer.C1ReportViewer.html) on the page. The next step is to invoke the [LoadDocument](/componentone/api/wpf/online-reportviewer/dotnet-framework-api/C1.WPF.ReportViewer.4.6.2/C1.WPF.ReportViewer.C1ReportViewer.LoadDocument.html) method to add some content to the control. The [LoadDocument](/componentone/api/wpf/online-reportviewer/dotnet-framework-api/C1.WPF.ReportViewer.4.6.2/C1.WPF.ReportViewer.C1ReportViewer.LoadDocument.html) 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:

1.  Navigate to the Solution Explorer, right-click the project name, and select **Add │ Existing Item**.
2.  In the **Add Existing Item** dialog box, locate a PDF file. In the file type drop-down box, you may need to choose **All Files** to view the PDF file. Note that if you choose, you can instead pick another PDF file to use.
3.  In the Solution Explorer, click the PDF file you just added to the application (in this example, we'll assume the file is named **resource.pdf**). In the Properties window, set its **BuildAction** property to **Resource** and confirm that the **Copy to Output Directory** item is set to **Do not Copy**.
4.  Switch to Code view by right-clicking the page and selecting **View Code**. In the next steps you'll add XAML markup to your application to add content to the drop-down box.
5.  Add the following imports statement at the top of the page:
    
    ```vbnet
    Imports C1.WPF.ReportViewer
    ```
    
    ```csharp
    using C1.WPF.ReportViewer;
    ```
    
6.  Add the following code to the main class:
    
    ```vbnet
    Public Sub New()
        InitializeComponent()
        Dim resource = Application.GetResourceStream(New Uri("AppName;component/resource.pdf", UriKind.Relative))
    Me.C1ReportViewer1.LoadDocument(resource.Stream)
    End Sub
    ```
    
    ```csharp
    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](/componentone/api/wpf/online-reportviewer/dotnet-framework-api/C1.WPF.ReportViewer.4.6.2/C1.WPF.ReportViewer.C1ReportViewer.html) 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.

## See Also

**TBHSL**

[Loading Documents from Application Resources (Silverlight)](/componentone/docs/wpf/online-reportviewer/reportviewerforwpfta/loadingdocumentsinto/Loading_Documents_from_Application_Resources)

[Loading Documents from Files on the Client Machine (Silverlight)](/componentone/docs/wpf/online-reportviewer/reportviewerforwpfta/loadingdocumentsinto/Loading_Documents_from_Files_on_the_Client_Machine)

[Loading Documents from Files on the Server (Silverlight)](/componentone/docs/wpf/online-reportviewer/reportviewerforwpfta/loadingdocumentsinto/Loading_Documents_from_Files_on_the_Server)

[Creating and Loading Reports Dynamically (Silverlight)](/componentone/docs/wpf/online-reportviewer/reportviewerforwpfta/loadingdocumentsinto/Creating_and_Loading_Reports_Dynamically)