Interaction modes in Flutter PDF Viewer (SfPdfViewer)

8 Jun 20221 minute to read

The SfPdfViewer supports the following interaction modes for easy interaction with the PDF documents on a desktop web browser,

  • selection
  • pan

NOTE

On a touch device, setting the interactionMode property to the selection mode will have no effect since panning is the default mode for scrolling and the selection is made by long-pressing a word in the document.

Selection mode

By default, the selection interaction mode will be enabled on a desktop web browser and allows users to select and copy text from the PDF files. This also helps to copy and share the text content. Refer to the following code to enable the selection mode in SfPdfViewer.

@override
Widget build(BuildContext context) {
  return Scaffold(
      body: SfPdfViewer.network(
              'https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf', 
              interactionMode: PdfInteractionMode.selection));
}

Pan mode

In pan mode, the dragging and scrolling of the pages can be performed in any direction using the mouse and touch interactions on a desktop web browser, but the text selection cannot be performed. Refer to the following code to enable the pan mode in SfPdfViewer.

@override
Widget build(BuildContext context) {
  return Scaffold(
      body: SfPdfViewer.network(
              'https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf', 
              interactionMode: PdfInteractionMode.pan));
}