updateHeaderFooter method
Replaces the document header and footer configuration.
The change is kept in the document memory. Call save or saveAs to persist it to the file.
Since v3.2.0
example:
final pageCount = await controller.document.getPageCount();
final success = await controller.document.updateHeaderFooter(
CPDFHeaderFooter(
pages: List<int>.generate(pageCount, (index) => index),
margin: const EdgeInsets.all(36),
slots: const <CPDFHeaderFooterSlot>[
CPDFHeaderFooterSlot(
position: CPDFHeaderFooterPosition.headerLeft,
text: 'ComPDFKit',
),
CPDFHeaderFooterSlot(
position: CPDFHeaderFooterPosition.footerCenter,
text: 'Page <<1>>',
),
],
),
);
Implementation
Future<bool> updateHeaderFooter(CPDFHeaderFooter headerFooter) async {
final validationError = headerFooter.validate();
if (validationError != null) {
debugPrint('updateHeaderFooter error: $validationError');
return false;
}
return await _channel.invokeMethod(
'update_header_footer',
headerFooter.toJson(),
);
}