pageNumber property
int
get
pageNumber
Current page number displayed in the SfPdfViewer.
Defaults to null
This example demonstrates how to get the current page's number and total page count.
class MyAppState extends State<MyApp>{
late PdfViewerController _pdfViewerController;
int _pageNumber=0;
int _pageCount=0;
@override
initState(){
_pdfViewerController = PdfViewerController();
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Syncfusion Flutter PdfViewer'),
actions: <Widget>[
Container(
width: 100,
height: 50,
child: TextField(
decoration: InputDecoration(labelText: '$_pageNumber / $_pageCount'),
)
),
IconButton(
icon: Icon(
Icons.keyboard_arrow_up,
color: Colors.white,
),
onPressed: () {
_pdfViewerController.previousPage();
setState(() {
_pageNumber = _pdfViewerController.pageNumber;
});
},
),
IconButton(
icon: Icon(
Icons.keyboard_arrow_down,
color: Colors.white,
),
onPressed: () {
_pdfViewerController.nextPage();
setState(() {
_pageNumber = _pdfViewerController.pageNumber;
});
},
),
],
),
body: SfPdfViewer.asset(
'assets/flutter-succinctly.pdf',
controller: _pdfViewerController,
onDocumentLoaded: (PdfDocumentLoadedDetails details){
setState(() {
_pageNumber = _pdfViewerController.pageNumber;
_pageCount = _pdfViewerController.pageCount;
});
}
),
),
);
}
}
Implementation
int get pageNumber {
return _currentPageNumber;
}