Back to Devexpress

Get Started with WinForms PDF Viewer (.NET)

windowsforms-405119-controls-and-libraries-pdf-viewer-getting-started-get-started-pdf-viewer-net.md

latest3.6 KB
Original Source

Get Started with WinForms PDF Viewer (.NET)

  • Jan 23, 2025
  • 4 minutes to read

This tutorial illustrates how to use the WinForms PDF Viewer control (PdfViewer) to create a simple PDF Viewer application and adjust its appearance. The application targets .NET.

The following controls are used in this tutorial:

Design Time

Follow this step-by-step guide to create a PDF Viewer Application in Visual Studio:

  1. Run Microsoft Visual Studio and create a new Windows Forms App project.

  2. Install the following packages for your WinForms application:

  3. Drop the PdfViewer item from the DX.25.2: Common Controls toolbox tab onto the form.

  4. Click the PDF Viewer’s smart tag and select Dock in parent container in the PDFViewer Tasks menu. This allows the PDF Viewer to expand to the form’s size.

  5. Create the Command UI. In the PDFViewer Tasks smart tag menu, select Create Ribbon to add a RibbonControl to the PdfViewer.

  6. In the PdfViewer Tasks smart tag menu, select the required ribbon pages or click Create All Bars to add all available ribbon pages simultaneously.

  7. Load a document to the PDF Viewer. Click the PdfViewer’s smart tag to invoke its actions list. In the Actions list, click the Load PDF file… link.

  8. Run the project to see the result: Result.

Tip

Use the DevExpress cross-IDE Template Kit to create WinForms projects based on templates. Project templates cover a broader range of usage scenarios when compared to our Template Gallery for .NET Framework. New project templates support hybrid app development and MVVM.

The DevExpress Template Kit includes project templates for .NET 8+ and C# only.

Runtime

  1. Run Microsoft Visual Studio and create a new Windows Forms App project.

  2. Install the following packages for your WinForms application:

  3. In the Form.Load event, use the following code to add PdfViewer to a WinForms application at runtime:

  4. To load a document, call the PdfViewer.LoadDocument() method: How to: Load a PDF Document from a File.

  5. Create the Command UI. Call PdfViewer.CreateRibbon() to add a RibbonControl to the PdfViewer at runtime.

Result

Run the application and try the PDF Viewer features. Load and navigate the document, highlight text, check the attachments, or print the result.

What’s Next