Touch interaction events in Xamarin Pdf Viewer (SfPdfViewer)

16 Mar 20223 minutes to read

Tapped

The Tapped event is triggered when the user taps on the document display area of the PDF Viewer control. The event argument of this event contains the following information:

  • PageNumber : The page number where the tap event occurred.
  • Position : The tapped position with respect to the PDF Viewer’s client area.
  • PagePosition : The tapped position with respect to the PDF page.

DoubleTapped

The DoubleTapped event is triggered when the user double taps on the document display area of the PDF Viewer control. The event argument of this event contains the following information:

  • PageNumber : The page number where the double tap event occurred.
  • Position : The double tapped position with respect to the PDF Viewer’s client area.
  • PagePosition : The double tapped position with respect to the PDF page.

LongPressed

The LongPressed event is triggered when the user long presses on the document display area of the PDF Viewer control. The event argument of this event contains the following information:

  • PageNumber : The page number where the long press event occurred.
  • Position : The long pressed position with respect to the PDF Viewer’s client area.
  • PagePosition : The long pressed position with respect to the PDF page.
<Grid x:Name="pdfViewGrid">
<syncfusion:SfPdfViewer x:Name="pdfViewerControl" Tapped="PdfViewerControl_Tapped"
DoubleTapped="PdfViewerControl_DoubleTapped" LongPressed="PdfViewerControl_LongPressed"
InputFileStream="{Binding PdfDocumentStream}"/>
</Grid>
public MainPage()
{
InitializeComponent();

}

private void PdfViewerControl_LongPressed(object sender, Syncfusion.SfPdfViewer.XForms.TouchInteractionEventArgs e)
{
//Gets the page number of the PDF Viewer where you tapped.
int pageNumber = e.PageNumber;
//Gets the position of the PDF Viewer's client area where you tapped.
Point position = e.Position;
//Gets the position of the PDF page where you tapped.
Point pagePosition = e.PagePosition;
}

private void PdfViewerControl_DoubleTapped(object sender, Syncfusion.SfPdfViewer.XForms.TouchInteractionEventArgs e)
{
//Gets the page number of the PDF Viewer where you double tapped.
int pageNumber = e.PageNumber;
//Gets the position of the PDF Viewer's client area where you double tapped.
Point position = e.Position;
//Gets the position of the PDF page where you double tapped.
Point pagePosition = e.PagePosition;
}

private void PdfViewerControl_Tapped(object sender, Syncfusion.SfPdfViewer.XForms.TouchInteractionEventArgs e)
{
//Gets the page number of the PDF Viewer where you long pressed.
int pageNumber = e.PageNumber;
//Gets the position of the PDF Viewer's client area where you long pressed.
Point position = e.Position;
//Gets the position of the PDF page where you long pressed.
Point pagePosition = e.PagePosition;
}

NOTE

You can refer to our Xamarin PDF Viewer feature tour page for its groundbreaking feature representations. You can also explore our Xamarin.Forms PDF Viewer example to knows the functionalities of each feature.