updateBackground method
Replaces the document background configuration.
An image background requires a local CPDFBackground.imagePath because native SDKs cannot read the source image back from an existing document. Call save or saveAs to persist the change.
Since v3.2.0
example:
final pageCount = await controller.document.getPageCount();
final success = await controller.document.updateBackground(
CPDFBackground.color(
pages: List<int>.generate(pageCount, (index) => index),
color: Colors.amber,
opacity: 0.35,
),
);
Implementation
Future<bool> updateBackground(CPDFBackground background) async {
final validationError = background.validateForUpdate();
if (validationError != null) {
debugPrint('updateBackground error: $validationError');
return false;
}
return await _channel.invokeMethod(
'update_background',
background.toJson(),
);
}