PdfViewerController class
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
-
- Object
- ChangeNotifier
- PdfViewerController
Constructors
Properties
- annotationMode ↔ PdfAnnotationMode
-
Gets or sets a value indicating the type of annotation that should be drawn using UI interaction on the PDF pages.
getter/setter pair
- annotationSettings ↔ PdfAnnotationSettings
-
Gets or sets the default annotation settings.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- pageCount → int
-
Total page count of the document loaded in the SfPdfViewer.
no setter
- pageNumber → int
-
Current page number displayed in the SfPdfViewer.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollOffset → Offset
-
The current scroll offset of the SfPdfViewer widget.
no setter
- zoomLevel ↔ double
-
Zoom level of a document in the SfPdfViewer.
getter/setter pair
Methods
-
addAnnotation(
Annotation annotation) → void - Adds the given annotation to the page represented by the annotation’s PageNumber property..
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
clearFormData(
{int pageNumber = 0}) → void - Clears the form fields data in the PDF document.
-
clearSelection(
) → bool - Clears the text selection in SfPdfViewer.
-
deselectAnnotation(
Annotation annotation) → void - Deselects the given annotation.
-
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
-
exportFormData(
{required DataFormat dataFormat}) → List< int> -
Export the form data with the specified
DataFormat
and return the bytes as list of int. -
firstPage(
) → void - Navigates to the first page of a PDF document.
-
getAnnotations(
) → List< Annotation> - Gets the list of annotations in the PDF.
-
getFormFields(
) → List< PdfFormField> - Gets the form fields data in the document.
-
importFormData(
List< int> inputBytes, DataFormat dataFormat, [bool continueImportOnError = false]) → void -
Imports the form data with the specified
DataFormat
. -
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 nonexistent 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.
-
removeAllAnnotations(
{int pageNumber = 0}) → void - Removes all annotations from the PDF document.
-
removeAnnotation(
Annotation annotation) → void - Removes the given annotation from the page.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
saveDocument(
{PdfFlattenOption flattenOption = PdfFlattenOption.none}) → Future< List< int> > - Saves the document and return the saved bytes as future list of int.
-
searchText(
String searchText, {TextSearchOption? searchOption}) → PdfTextSearchResult - Searches the given text in the document.
-
selectAnnotation(
Annotation annotation) → void - Selects the given annotation.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited