Articles in this section
Category / Section

How to zoom PdfDocumentView with Ctrl and mouse wheel

1 min read

To zoom the PdfDocumentView using the mouse/keyboard, the user can achieve this by adding the PreviewMouseWheel and KeyDown Events in the Sample level. Please find below the code snippet to zoom the Pdf Page using the mouse/keyboard combination in PdfDocumentView.

Perform page zooming using mouse

  • Wire the PreviewMouseWheel Event from PdfDocumentView.

C#

//Wire PdfDocumentView PreviewMouseWheel event
PdfDocumentView1.PreviewMouseWheel += PdfDocumentView1_PreviewMouseWheel;
  • Check whether the control key is pressed and use the Delta property to find mouse wheel direction is upward or downward, then add a customized zoom level based on the mouse wheel direction.

C#

//Handle the PreviewMouseWheel Event
private void PdfDocumentView1_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
//Check the Keyboard Key as Control
if (Keyboard.Modifiers == ModifierKeys.Control)
{
//Check if the mouse wheel direction is upward or downward 
if (e.Delta > 0)
PdfDocumentView1.ZoomTo(PdfDocumentView1.ZoomPercentage + 10);
else
PdfDocumentView1.ZoomTo(PdfDocumentView1.ZoomPercentage - 10);
}
}

View Sample in GitHub

See Also

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied