Guides
Move Pages
Swap the positions of two pages in the document. Here are the steps:
- Specify the two page numbers to swap
- Call the swap pages interface
Using CPDFReaderWidget:
dart
CPDFReaderWidgetController? _controller;
// Initialize CPDFReaderWidget and get controller in onCreated callback
CPDFReaderWidget(
document: documentPath,
configuration: CPDFConfiguration(),
onCreated: (controller) {
setState(() {
this._controller = controller;
});
},
);
bool result = await document.movePage(fromIndex: 0, toIndex: 1);
if(result){
controller.reloadPages2();
}Using CPDFDocument:
dart
// Create and open the document
CPDFDocument document = await CPDFDocument.createInstance();
var error = await document.open(pdfFilePath);
if (error == CPDFDocumentError.success) {
bool result = await document.movePage(fromIndex: 0, toIndex: 1);
}