CPDFWatermark.image constructor
CPDFWatermark.image({
- required String imagePath,
- required List<
int> pages, - int index = -1,
- double scale = 1.0,
- double rotation = 45,
- double opacity = 1,
- CPDFWatermarkVerticalAlignment verticalAlignment = CPDFWatermarkVerticalAlignment.center,
- CPDFWatermarkHorizontalAlignment horizontalAlignment = CPDFWatermarkHorizontalAlignment.center,
- double verticalOffset = 0,
- double horizontalOffset = 0,
- bool isFront = true,
- bool isTilePage = false,
- double horizontalSpacing = 0,
- double verticalSpacing = 0,
- bool isImageExported = false,
Image watermark constructor
This constructor creates an image watermark with customizable properties.
imagePath: The file path to the image used as a 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)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 isCPDFWatermarkVerticalAlignment.center.horizontalAlignment: The horizontal alignment of the watermark on the page. Default isCPDFWatermarkHorizontalAlignment.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 istrue.isTilePage: Whether to tile the watermark across the page. Default isfalse.horizontalSpacing: Horizontal spacing between tiled watermarks. Default is 0.0.verticalSpacing: Vertical spacing between tiled watermarks. Default is 0.0.
Example:
CPDFWatermark.image(
imagePath: '/path/to/image.png',
pages: [0, 1, 2],
scale: 0.5,
);
Implementation
CPDFWatermark.image({
required this.imagePath,
required this.pages,
this.index = -1,
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,
this.isImageExported = false,
}) : type = CPDFWatermarkType.image,
textContent = '',
textColor = Colors.black,
fontSize = 24;