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
- Create a new WinForms application.
- Navigate to the Toolbox, drag and drop C1FlexViewer control on the form. Adjust the position and size of FlexViewer according to your requirement.
- Drag and drop C1PdfDocumentSource control on the form. It appears in the form's component tray.
- In Properties Window, go to the c1FlexViewer's properties, click the dropdown arrow next to DocumentSource property value field and select c1PdfDocumentSource1.
- 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.
- 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
- Create a new WinForms application.
- Drag and drop C1PdfDocumentSource and C1FlexViewer on the form.
Step 2: Load the PDF file in FlexViewer
- Switch to the code view and add the following namespace.
- Add a PDF file to the project. In our case, we have used PDF file named DefaultDocument.pdf from the product sample.
- 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.
- Render the PDF file in the FlexViewer control using DocumentSource property.
Step 3: Build and run the project
- Press Ctrl+Shift+B to build the project.
- Press F5 to run the application.
See Also