Syncfusion AI Assistant

How can I help you?

Getting Started with Windows Forms PDF Viewer (PdfViewerControl)

22 Jun 20264 minutes to read

This section briefly explains how to include the Syncfusion® WinForms PdfViewer component in Windows Forms App using Visual Studio.

Prerequisites

Create a new Windows Forms App in Visual Studio

You can create a Windows Forms Application using Visual Studio via Microsoft Templates or the Syncfusion® Windows Forms.

Assemblies Deployment

To add a WinForms PdfViewer component to your application by installing it via NuGet packages(Recommended) or by manually adding the required assemblies to the project.

Install Syncfusion® Windows Forms PdfViewer NuGet packages

To add Windows Forms PdfViewer component in the application, open the NuGet package manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), search and install:

Syncfusion.PdfViewer.Windows

Add Syncfusion® WinForms PdfViewer Assemblies

Below table describes, list of assemblies required to be added in project when the WinForms PdfViewer control is used in your application.

Assembly Description
Syncfusion.Compression.Base.dll This library handles various compression and decompression operations that are used in the PDF file internally.
Syncfusion.Pdf.Base.dll This library contains the PDF reader and creator that supports the PDF Viewer.
Syncfusion.PdfToImageConverter.Base.dll This library is responsible for Pdfium integration and image generation, enhancing the capabilities of the PDF Viewer.
Syncfusion.PdfViewer.Windows.dll This component contains the rendering area and other related UI elements.
Syncfusion.Shared.Base.dll This component contains various UI controls (ColorPickerPalette and Numeric UpDown) that are used in the PDF Viewer.

NOTE

  • Starting with version 23.1.x, Syncfusion PdfToImageConverter is necessary for PdfViewer applications.
  • Starting with v16.2.0.x, if you reference Syncfusion®; assemblies from trial setup or from the NuGet feed, you also have to include a license key in your projects. Please refer to this link to know about registering Syncfusion® license key in your Windows Forms application to use our components.

Add Windows Forms PdfViewer component

WinForms PdfViewer control can be added to an application either through the designer (XAML) or programmatically using code.

  1. Open your form in the designer. Add the Syncfusion®; controls to your .NET toolbox in Visual Studio if you haven’t done so already (the install would have automatically done this unless you selected not to complete toolbox integration during installation).

    Windows forms pdfviewer drag and drop from toolbox

  2. Drag the PdfViewerControl from the toolbox onto the form. Appearance and behavior related aspects of the PdfViewerControl can be controlled by setting the appropriate properties through the properties grid.

    Windows forms pdfviewer displays properties window of control

  3. This will add the instance ‘pdfViewerControl1’ to the Designer cs file. The PDF can be loaded in the Form1.cs file using the Load method.

//Loading the document in the PdfViewerControl
pdfViewerControl1.Load("Sample.pdf");
'Loading the document in the PdfViewerControl
pdfViewerControl1.Load("Sample.pdf")
  1. Add Syncfusion.Windows.Forms.PdfViewer namespace in Form1.cs.
using Syncfusion.Windows.Forms.PdfViewer;
Imports Syncfusion.Windows.Forms.PdfViewer
  1. Create PdfViewerControl instance and load the PDF in Form1.cs.
//Initializing the PdfViewerControl
PdfViewerControl pdfViewerControl1 = new PdfViewerControl();

//Add PdfViewerControl to the Form
Controls.Add(pdfViewerControl1);
//Docking the control to all edges of its containing control and sizing appropriately.
pdfViewerControl1.Dock = DockStyle.Fill;

//Loading the document in the PdfViewerControl
pdfViewerControl1.Load("Sample.pdf");
'Initializing the PdfViewerControl
Dim pdfViewerControl1 As PdfViewerControl = New PdfViewerControl()

'Add PdfViewerControl to the Form
Controls.Add(pdfViewerControl1)
'Docking the control to all edges of its containing control and sizing appropriately.
pdfViewerControl1.Dock = DockStyle.Fill

'Loading the document in the PdfViewerControl
pdfViewerControl1.Load("Sample.pdf")

NOTE

View Sample in GitHub.

See Also