PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Use updateWatermark() with the watermark index and a new CPDFWatermark value. Read the original watermark first, then use copyWith() to change only the properties you need.
final CPDFWatermark? watermark = await document.getWatermark(
0,
exportImage: true,
);
if (watermark != null) {
final bool success = await document.updateWatermark(
watermark.index,
watermark.copyWith(
textContent: 'Updated Confidential',
textColor: Colors.blue,
fontSize: 36,
opacity: 0.75,
),
);
print('Update watermark result: $success');
}When updating an image watermark, pass a new imagePath only if you want to replace the image. If imagePath is empty, the SDK keeps the existing image and updates the other watermark properties.