showAddWatermarkView method

Future<void> showAddWatermarkView({
  1. CPDFWatermarkConfig? config,
})

Displays the Add Watermark view, allowing users to add text and/or image watermarks to the current document.

The watermark can be configured through CPDFWatermarkConfig. By default, both text and image watermark types are enabled.

Example:

final imagePath = await extractAsset(context, 'images/ic_logo.png');
await controller.showAddWatermarkView(
  config: CPDFWatermarkConfig(
    saveAsNewFile: true,
    types: [CPDFWatermarkType.text, CPDFWatermarkType.image],
    image: imagePath.path,
    text: 'ComPDFKit Flutter',
    textSize: 40,
    textColor: Colors.red,
    rotation: -45,
    opacity: 180,
    scale: 2.0,
    isFront: true,
  ),
);

On Android, images can be provided either as:

  • A drawable resource name ('ic_logo') → R.drawable.ic_logo
  • A file path

On iOS, images should be provided as:

  • A bundled image file name ('ic_logo')
  • A file path

Implementation

Future<void> showAddWatermarkView({CPDFWatermarkConfig? config}) async {
  await _channel.invokeMethod('show_add_watermark_view', config?.toJson());
}