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,
       ),
     ),
   );
 }
}
Inheritance

Constructors

PdfViewerController()

Properties

hashCode int
The hash code for this object.
read-onlyinherited
hasListeners bool
Whether any listeners are currently registered.
read-onlyinherited
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-onlyinherited
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(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
clearSelection() bool
Clears the text selection in SfPdfViewer.
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
inherited
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
notifyListeners() → void
Call all the registered listeners.
inherited
previousPage() → void
Navigates to the previous page of a PDF document.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
searchText(String searchText, {TextSearchOption? searchOption}) 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