- Page Border
- Page Events
Contact Support
Working with PDF Pages in WPF Pdf Viewer
7 Apr 20258 minutes to read
Page Border
The PageBorder allows you to customize the border visibility and color of the pages that are being displayed in the PDF Viewer.
NOTE
This border customization applies only when viewing the PDF file in the PDF viewer and it will not affect the saved or printed file from the PDF Viewer.
Color
The Color property of the PageBorder allows you to customize the border color of the pages that are being displayed in the PDF Viewer. The default border color of the pages is Black
. Refer to the following code sample to set a different color to the border of the pages.
using System.Windows;
using Syncfusion.Windows.PdfViewer;
namespace PdfViewerDemo
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class MainWindow : Window
{
#region Constructor
public MainWindow()
{
InitializeComponent();
//Create an instance for `PageBorder`.
PageBorder pageBorder = new PageBorder();
//Set the `Color` property.
pageBorder.Color = System.Drawing.Color.Red;
//Assign the 'PageBorder' propery of PDF Viewer.
pdfViewer.PageBorder = pageBorder;
//Load the PDF file.
pdfViewer.Load(@"Sample.pdf");
}
#endregion
}
}
Visibility
The PageBorder property allows you to show or hide the border of the pages that are being displayed in the PDF Viewer. By default, the border of the pages will be visible. Refer to the following code sample to hide the border of the pages.
using System.Windows;
using Syncfusion.Windows.PdfViewer;
namespace PdfViewerDemo
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class MainWindow : Window
{
#region Constructor
public MainWindow()
{
InitializeComponent();
//Create an instance for `PageBorder`.
PageBorder pageBorder = new PageBorder();
//Set the `IsVisible` property as false to hide the page border.
pageBorder.IsVisible = false;
//Assign the 'PageBorder' propery of PDF Viewer.
pdfViewer.PageBorder = pageBorder;
//Load the PDF file.
pdfViewer.Load(@"Sample.pdf");
}
#endregion
}
}
NOTE
You can refer to our WPF PDF Viewer feature tour page for its groundbreaking feature representations. You can also explore our WPF PDF Viewer example to know how to render and configure the pdfviewer.
Page Events
The PdfViewerControl notifies users of interactions with PDF pages through events such as PageClicked and PageMouseMove.
Page Clicked
The PageClicked event occurs when users click on a PDF page. It provides the information about the page index and the clicked position on the page. The following code shows how to wire the event in PdfViewerControl.
using System.Windows;
using Syncfusion.Windows.PdfViewer;
namespace WPF_PDFViewer
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
//Load the PDF file
pdfViewer.Load("F Sharp Succinctly.pdf");
//Wire the PageClicked event
pdfViewer.PageClicked += PdfViewer_PageClicked;
}
/// <summary>
/// Handle the PageClicked Event of PdfViewerControl
/// </summary>
private void PdfViewer_PageClicked(object sender, PageClickedEventArgs args)
{
//Get the page index on the page where you clicked
int pageIndex = args.PageIndex;
//Get the position on the page where you clicked
Point position = args.Position;
//Insert Your code Here.
}
}
}
Page Mouse Move
The PageMouseMove event occurs when a user move the mouse on a PDF page. It provides information about the page index and the position on the page where the mouse has moved. The following code shows how to wire the event in PdfViewerControl.
using System.Windows;
using Syncfusion.Windows.PdfViewer;
namespace WPF_PDFViewer
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
//Load the PDF file
pdfViewer.Load("F Sharp Succinctly.pdf");
//Wire the PageMouseMove event
pdfViewer.PageMouseMove += PdfViewer_PageMouseMove;
}
/// <summary>
/// Handle the PageMouseMove Event of PdfViewerControl
/// </summary>
private void PdfViewer_PageMouseMove(object sender, PageMouseMoveEventArgs args)
{
//Get the page index on the page where you clicked
int pageIndex = args.PageIndex;
//Get the position on the page where you clicked
Point position = args.Position;
//Insert Your code Here.
}
}
}