ComponentOne Document Library for WinForms
Quick Start
PdfDocumentSource for WinForms > Quick Start

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 at design time

  1. Create a new WinForms application.
  2. Navigate to the Toolbox, drag and drop C1FlexViewer control on the form. Adjust the position and size of FlexViewer according to your requirement.
  3. Drag and drop C1PdfDocumentSource control on the form. It appears in the form's component tray.
  4. In Properties Window, go to the c1FlexViewer's properties, click the dropdown arrow next to DocumentSource property value field and select c1PdfDocumentSource1.
  5. Select C1PdfDocumentSource component and go to properties of c1PdfDocumentSource1 in Properties window. Locate DocumentLocation property and enter the full path of the PDF file you want to show.
  6. Build and run the application. The PDF is rendered in FlexViewer control.

To load a PDF file in FlexViewer programmatically

Step 1: Setting up the application

  1. Create a new WinForms application.
  2. Drag and drop C1PdfDocumentSource and C1FlexViewer on the form.

Step 2: Load the PDF file in FlexViewer

  1. Switch to the code view and add the following namespace.
    Imports C1.Win.C1Document
    
    using C1.Win.C1Document;
    
  2. Add a PDF file to the project. In our case, we have used PDF file named DefaultDocument.pdf from the product sample.
  3. Double-click the form and write the following code in the Form1_Load event 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.
    C1FlexViewer1.DocumentSource = pds
    
    c1FlexViewer1.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