CPDFWatermark.text constructor

CPDFWatermark.text({
  1. required String textContent,
  2. required List<int> pages,
  3. int index = -1,
  4. Color textColor = Colors.black,
  5. int fontSize = 24,
  6. double scale = 1.0,
  7. double rotation = 45,
  8. double opacity = 1,
  9. CPDFWatermarkVerticalAlignment verticalAlignment = CPDFWatermarkVerticalAlignment.center,
  10. CPDFWatermarkHorizontalAlignment horizontalAlignment = CPDFWatermarkHorizontalAlignment.center,
  11. double verticalOffset = 0,
  12. double horizontalOffset = 0,
  13. bool isFront = true,
  14. bool isTilePage = false,
  15. double horizontalSpacing = 0,
  16. double verticalSpacing = 0,
})

Text watermark constructor

This constructor creates a text watermark with customizable properties.

  • textContent: The text content of the watermark. (Required)
  • pages: A list of page indices where the watermark should be applied, e.g., [0, 1, 2, 3] represents pages 1 through 4. (Required)
  • textColor: The color of the watermark text. Default is Colors.black.
  • fontSize: The font size of the watermark text. Default is 24.
  • scale: Scaling factor for the watermark. Default is 1.0.
  • rotation: Rotation angle of the watermark in degrees. Default is 45.0.
  • opacity: The transparency of the watermark, where 1.0 is fully opaque and 0.0 is fully transparent. Default is 1.0.
  • verticalAlignment: The vertical alignment of the watermark on the page. Default is CPDFWatermarkVerticalAlignment.center.
  • horizontalAlignment: The horizontal alignment of the watermark on the page. Default is CPDFWatermarkHorizontalAlignment.center.
  • verticalOffset: The vertical offset of the watermark relative to the alignment position. Default is 0.0.
  • horizontalOffset: The horizontal offset of the watermark relative to the alignment position. Default is 0.0.
  • isFront: Whether the watermark should appear in front of the content. Default is true.
  • isTilePage: Whether to tile the watermark across the page. Default is false.
  • horizontalSpacing: Horizontal spacing between tiled watermarks. Default is 0.0.
  • verticalSpacing: Vertical spacing between tiled watermarks. Default is 0.0.

Example:

CPDFWatermark.text(
  textContent: 'Confidential',
  pages: [0, 1, 2],
  textColor: Colors.red,
  fontSize: 24,
);

Implementation

CPDFWatermark.text({
  required this.textContent,
  required this.pages,
  this.index = -1,
  this.textColor = Colors.black,
  this.fontSize = 24,
  this.scale = 1.0,
  this.rotation = 45,
  this.opacity = 1,
  this.verticalAlignment = CPDFWatermarkVerticalAlignment.center,
  this.horizontalAlignment = CPDFWatermarkHorizontalAlignment.center,
  this.verticalOffset = 0,
  this.horizontalOffset = 0,
  this.isFront = true,
  this.isTilePage = false,
  this.horizontalSpacing = 0,
  this.verticalSpacing = 0,
})  : type = CPDFWatermarkType.text,
      imagePath = '',
      isImageExported = false;