PdfViewerController class Null safety

An object that is used to control the navigation and zooming operations in the SfPdfViewer.

A PdfViewerController is served for several purposes. It can be used to change zoom level and navigate to the desired page, position and bookmark programmatically on SfPdfViewer by using the zoomLevel property and jumpToPage, jumpTo and jumpToBookmark methods.

This example demonstrates how to use the PdfViewerController of SfPdfViewer.

class MyAppState extends State<MyApp>{
 late PdfViewerController _pdfViewerController;

 @override
 void initState(){
   _pdfViewerController = PdfViewerController();
   super.initState();
 }

 @override
 Widget build(BuildContext context) {
   return MaterialApp(
     home: Scaffold(
       appBar: AppBar(
          title: Text('Syncfusion Flutter PdfViewer'),
          actions: <Widget>[
             IconButton(
                icon: Icon(
                   Icons.zoom_in,
                    color: Colors.white,
                ),
                onPressed: () {
                   _pdfViewerController.zoomLevel = 2;
                },
             ),
             IconButton(
                icon: Icon(
                   Icons.arrow_drop_down_circle,
                    color: Colors.white,
                ),
                onPressed: () {
                   _pdfViewerController.jumpToPage(5);
                },
             ),
          ],
       ),
       body: SfPdfViewer.asset(
         'assets/flutter-succinctly.pdf',
         controller: _pdfViewerController,
       ),
     ),
   );
 }
}

Constructors

PdfViewerController()

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
listener ↔ _PdfControllerListener
read / write, inherited
pageCount int
Total page count of the document loaded in the SfPdfViewer. [...]
read-only
pageNumber int
Current page number displayed in the SfPdfViewer. [...]
read-only
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
scrollOffset Offset
The current scroll offset of the SfPdfViewer widget.
read-only
zoomLevel double
Zoom level of a document in the SfPdfViewer. [...]
read / write

Methods

addListener(_PdfControllerListener listener) → void
inherited
clearSelection() bool
Clears the text selection in SfPdfViewer. [...]
firstPage() → void
Navigates to the first page of a PDF document. [...]
jumpTo({double xOffset = 0.0, double yOffset = 0.0}) → void
Jumps the scroll position of SfPdfViewer to the specified offset value. [...]
jumpToBookmark(PdfBookmark bookmark) → void
Navigates to the specified bookmark location in a PDF document. [...]
jumpToPage(int pageNumber) → void
Navigates to the specified page number in a PDF document. [...]
lastPage() → void
Navigates to the last page of a PDF document. [...]
nextPage() → void
Navigates to the next page of a PDF document. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
notifyPropertyChangedListeners({String? property}) → void
@protected, inherited
previousPage() → void
Navigates to the previous page of a PDF document. [...]
removeListener(_PdfControllerListener listener) → void
inherited
searchText(String searchText, {TextSearchOption? searchOption}) Future<PdfTextSearchResult>
Searches the given text in the document. [...]
toString() String
A string representation of this object. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited