This tutorial illustrates how to use the
WinForms PDF Viewer control
to create a simple PDF Viewer application and adjust its appearance.
Watch Video:
WinForms PDF Viewer: Getting Started
Create a PDF Viewer Application
Run Microsoft® Visual Studio and create a new
Windows Forms Application
project.
Drop the
PdfViewer
item from the
DX.
24.1
: Common Controls
toolbox tab onto the form.
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.
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.
The
Open
dialog box appears. In this dialog, locate the document to be opened and click
Open
.
Create Command UI
Design Time
Select
Create Ribbon
in the
PDFViewer Tasks
menu to add a RibbonControl to the PdViewer.
Select necessary ribbon pages in the
PdfViewer Tasks
menu or click
Create All Bars
to add all available ribbon pages at once. You can customize the created ribbon afterward: change the
ribbon style
, add new ribbon elements, modify or remove the existing items.
You can also implement a bar interface. You can upgrade it to the ribbon interface at any time (e.g., when converting the entire application).
Runtime
Use the
PdfViewer.CreateRibbon()
or
PdfViewer.CreateBars()
method overloads to add a ribbon or a bar manager to the PdfViewer at runtime.
VB.NET
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraPdfViewer;
//Create all PDF ribbon tabs
pdfViewer.CreateRibbon(PdfViewerToolbarKind.All);
//Create main toolbar
pdfViewer.CreateBars(PdfViewerToolbarKind.Main);
Imports DevExpress.XtraBars.Ribbon
Imports DevExpress.XtraPdfViewer
' Create all PDF ribbon tabs
pdfViewer.CreateRibbon(PdfViewerToolbarKind.All)
'Create main toolbar
pdfViewer.CreateBars(PdfViewerToolbarKind.Main)
Result
Run the application and try the PDF Viewer features. Load and navigate the document, highlight text, check the attachments or print the result.
Note
The PDF Viewer shows bookmarks within its navigation pane for a document that contains them. So you can quickly locate and link to points of interest within a document. For more information, see the Bookmarks topic.
You can also see file attachments and thumbnails in theAttachments and Page Thumbnails panels on the navigation pane.
Change the Application’s Appearance
Change the Application’s Skin
Use Bitmap or Vector Icons
The newly created PDF Viewer application uses vector icons. This ensures that the application is rendered correctly on high-DPI devices.
Set the static WindowsFormsSettings.AllowDefaultSvgImages property to DefaultBoolean.False at the application’s startup to use bitmap icons in your application.
VB.NET
static void Main()
DevExpress.XtraEditors.WindowsFormsSettings.AllowDefaultSvgImages = DevExpress.Utils.DefaultBoolean.False;
// ...
Sub Main()
DevExpress.XtraEditors.WindowsFormsSettings.AllowDefaultSvgImages = DevExpress.Utils.DefaultBoolean.False
' ...
End Sub
The following images illustrate the standard PDF Viewer’s ribbon UI with default vector and bitmap icons:
SVG Icons
Bitmap Icons
Use Skinned Open/Save File Dialogs
You can replace standard WinForms Open File and Save File dialogs with skinned DevExpress counterparts.
Set the static WindowsFormsSettings.UseDXDialogs property to DefaultBoolean.True at the application’s startup to enable skinned dialogs in your application.
Note
Add the required assembly references to use skinned DevExpress dialogs. Refer to the Deployment topic for more information.
static void Main()
DevExpress.XtraEditors.WindowsFormsSettings.UseDXDialogs = DefaultBoolean.True;
// ...
Sub Main()
DevExpress.XtraEditors.WindowsFormsSettings.UseDXDialogs = DevExpress.Utils.DefaultBoolean.True
' ...
End Sub
Use of this site constitutes acceptance of our Website Terms of Use and Privacy Policy (Updated).
Cookies Settings