ComponentOne Document Library for WPF
PdfDocumentSource for WPF / Quick Start
In This Topic
    Quick Start
    In This Topic

    This quick start topic guides you through a step-by-step process of creating a simple application for loading a PDF file in the FlexViewer control. It uses a PDF file named DefaultDocument.pdf, taken from the C1PdfDocumentSource product sample.

    The following image shows a PDF file loaded in FlexViewer.

    To load a PDF file in FlexViewer programmatically

    Step 1: Setting up the application

    1. Create a new WPF application.
    2. Drag and drop C1FlexViewer control in the XAML view.

    Step 2: Load the PDF file in FlexViewer

    1. Switch to the code view and add the following namespace.
      Imports C1.WPF.Document
      
      using C1.WPF.Document;
      
    2. Add a PDF file to the project. In our case, we have used PDF file named DefaultDocument.pdf from the product sample.
    3. Add the following code in the MainWindow() class constructor to create an instance of C1PdfDocumentSource and load the PDF file using LoadFromFile method.
      Dim pds As New C1PdfDocumentSource()
      pds.LoadFromFile("..\..\DefaultDocument.pdf")
      
      C1PdfDocumentSource pds = new C1PdfDocumentSource();
      pds.LoadFromFile(@"..\..\DefaultDocument.pdf");
      
    4. Render the PDF file in the FlexViewer control using DocumentSource property.
      viewer.DocumentSource = pds
      
      viewer.DocumentSource = pds;
      

    Step 3: Build and run the project

    1. Press Ctrl+Shift+B to build the project.
    2. Press F5 to run the application.
    See Also