How to View the PDF Files in C# WinForms in WPF?
The WinForms PDF viewer control enables users to view and print PDF documents within WinForms applications. Features such as bookmarks, hyperlinks, and a table of contents facilitate seamless navigation both inside and outside the PDF files.
Steps to view PDF files in the C# Winforms using PdfViewerControl
Step 1:
- Create a new C# WinForms application
Step 2:
- Install the Syncfusion.PdfViewer.Windows NuGet package as a reference to the WinForms application.
Step 3:
- Add the following namespace in Form1.cs class.
using Syncfusion.Windows.Forms.PdfViewer;
Step 4:
- In the constructor, use the provided code to initialize the PDFViewer Control, properly add it to the form window, and utilize the Load method to load the PDF into the WinForms PDFViewer Control.
public Form1()
{
InitializeComponent();
//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(@"../../../Data/PDF_Succinctly.pdf");
}
The complete working sample to view PDF files in C# WinForms can be downloaded from GitHub
UI Customization
You can design and use your UI for interacting with PDF files using the PdfDocumentView control. This control is exclusive for customization purposes, and it supports only viewing PDF files without any other built-in UIs. We have exposed equivalent APIs for all the functionalities, and you can bind them to your custom UI to make use of all the features. Refer to our API reference for more details.
Toolbar customization
You can create and customize your toolbar by disabling the default toolbar in the PdfViewerControl. For additional information on how to adjust the toolbar’s visibility, please refer to this documentation.
Appearance customization
As it inherits from System.Windows.Forms.Form, you can change the appearance of the control to fit the look and feel of your application. You can customize the appearance either by creating your control template or by choosing any of the Syncfusion-supported built-in themes that are available in the Syncfusion.Shared.Base assembly.
Conclusion
I hope you enjoyed learning about how to create a PDF Viewer control in C# WinForms.
You can refer to our WinForms PDF Viewer page to learn about its other groundbreaking feature representations. You can also explore our WinForms PDF Viewer documentation to understand how to present and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarification, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!