Working with themes in Windows Forms PDF Viewer (PdfViewerControl)
15 Nov 20225 minutes to read
PDF Viewer provides support for various built-in themes, using which the default appearance of elements that are present in the control can be customized. This can be achieved using the ThemeName property of PdfViewerControl.
Assembly requirements
To set a theme to PdfViewerControl
, the theme assemblies should be added as a reference in the application, in addition to the control dependencies. Refer to the following table for the additional assembly details.
Themes | Assemblies required |
---|---|
Office2016Colorful Office2016Black Office2016DarkGray Office2016White |
No additional assemblies are required as the themes are included in the control assembly itself. |
Office2019Colorful | Syncfusion.Office2019Theme.WinForms |
HighContrastBlack | Syncfusion.HighContrastTheme.WinForms |
Office 2016 themes
It provides support for applying Office 2016 themes to PdfViewerControl
and its associated elements. Following are the Office 2016 themes that are supported in the PDF Viewer control:
- Office2016Colorful
- Office2016Black
- Office2016DarkGray
- Office2016White
Refer to the following code to apply Office 2016 dark gray theme to the PdfViewerControl
.
this.pdfViewerControl1.ThemeName = "Office2016DarkGray";
Me.pdfViewerControl1.ThemeName = "Office2016DarkGray"
The following image illustrates the appearance of the control after Office 2016 dark gray theme is applied.
NOTE
You can follow a similar step for all the other Office 2016 themes.
Office 2019 theme
It provides support for applying Office 2019 theme to PdfViewerControl
and its associated elements. Before applying this theme to the control, the Office2016Theme
assembly should be loaded in the main entry point of the application. Refer to the following code to load the assembly using SkinManager.
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
SkinManager.LoadAssembly(typeof(Syncfusion.WinForms.Themes.Office2019Theme).Assembly);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
Module Program
''' <summary>
''' The main entry point for the application.
''' </summary>
<STAThread>
Private Sub Main()
SkinManager.LoadAssembly(GetType(Syncfusion.WinForms.Themes.Office2019Theme).Assembly)
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New Form1())
End Sub
End Class
After loading the theme assembly, set the ThemeName
to Office2019Colorful
as explained in the following code.
this.pdfViewerControl1.ThemeName = "Office2019Colorful";
Me.pdfViewerControl1.ThemeName = "Office2019Colorful"
The following image illustrates the appearance of the control after this theme is applied.
High Contrast theme
It provides support for applying high contrast theme to PdfViewerControl
and its associated elements. Before applying this theme to the control, the Office2016Theme
assembly should be loaded in the main entry point of the application. Refer to the following code to load the assembly using SkinManager.
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
SkinManager.LoadAssembly(typeof(Syncfusion.WinForms.Themes.HighContrastTheme).Assembly);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
Module Program
''' <summary>
''' The main entry point for the application.
''' </summary>
<STAThread>
Private Sub Main()
SkinManager.LoadAssembly(GetType(Syncfusion.WinForms.Themes.HighContrastTheme).Assembly)
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New Form1())
End Sub
End Class
After loading the theme assembly, set the ThemeName
to HighContrastBlack
as explained in the following code.
this.pdfViewerControl1.ThemeName = "HighContrastBlack";
Me.pdfViewerControl1.ThemeName = "HighContrastBlack"
The following image illustrates the appearance of the control after this theme is applied.
Default theme
To clear the existing theme and set default theme to the control, set the ThemeName
to Default
as explained in the following code.
this.pdfViewerControl1.ThemeName = "Default";
Me.pdfViewerControl1.ThemeName = "Default"
Find the sample from this GitHub location.