updateWatermark method

Future<bool> updateWatermark(
  1. int index,
  2. CPDFWatermark watermark
)

Updates the watermark at index.

This method does not save the document. Call save or saveAs explicitly after updating watermarks.

Parameters:
index - The watermark index.
watermark - The new watermark properties.

Returns: true if the watermark is updated, false otherwise.

Since v2.6.8

example:

final CPDFWatermark? watermark = await controller.document.getWatermark(0);

if (watermark != null) {
  final bool success = await controller.document.updateWatermark(
    watermark.index,
    watermark.copyWith(
      textContent: 'Updated ComPDFKit',
      textColor: Colors.blue,
      opacity: 0.75,
    ),
  );
  print('Update watermark result: $success');
}

Implementation

Future<bool> updateWatermark(int index, CPDFWatermark watermark) async {
  final validationError = watermark.validateForUpdate();
  if (validationError != null) {
    debugPrint('updateWatermark error: $validationError');
    return false;
  }
  return await _channel.invokeMethod('update_watermark', {
    ...watermark.toJson(),
    'index': index,
  });
}