On Tap Event

Hi


Is there any way or sample for getting on tap event on PDF pages ?


Best wishes


2 Replies

HB Hamdi Boyaci December 27, 2022 07:36 PM UTC

or/ and LongPress event also.



DR Deepika Ravi Syncfusion Team December 29, 2022 01:43 AM UTC

Hi Hamdi Boyaci,

In SfPdfViewer, we have used the gestures to detect tapping and zooming, so when using the gestures in the main.dart , it does not trigger those gestures first instead, which triggers the gestures inside the SfPdfViewer widget. We recommend using the RawGestureDetector over the SfPdfViewer widget. The following code example also explains the same.

Code Snippet:

@override

  Widget build(BuildContext context) {

    return Scaffold(

      appBar: AppBar(

        title: const Text('Syncfusion Flutter PDF Viewer'),

      ),

      body: RawGestureDetector(

        gestures: {

          GestureRecognizer:

              GestureRecognizerFactoryWithHandlers<GestureRecognizer>(

            () => GestureRecognizer(), //constructor

            (GestureRecognizer instance) {

              //initializer

              instance.onTap = () => print('Tapped');

            },

          )

        },

        child: SfPdfViewer.network(

          'https://cdn.syncfusion.com/content/PDFViewer/flutter-succinctly.pdf',

          key: _pdfViewerKey,

        ),

      ),

    );

  }

}

 

class GestureRecognizer extends TapGestureRecognizer {

  @override

  void rejectGesture(int pointer) {

    acceptGesture(pointer);

  }

}


Regards,

Deepika R


Loader.
Up arrow icon