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. Get the original watermark first, then use copyWatermark() to change only the properties you need.
import { copyWatermark } from "@compdfkit_pdf_sdk/react_native";
const watermark = await pdfReaderRef.current?._pdfDocument.getWatermark(0);
if (watermark) {
const success = await pdfReaderRef.current?._pdfDocument.updateWatermark(
watermark.index,
copyWatermark(watermark, {
textContent: "Updated Confidential",
textColor: "#0066FF",
fontSize: 36,
opacity: 0.75,
})
);
console.log("Update watermark result:", success);
}When updating an image watermark, pass a new imagePath only if you need to replace the image content. If imagePath is empty, the SDK keeps the original image and updates the other properties.
const watermark = await pdfReaderRef.current?._pdfDocument.getWatermark(0);
if (watermark?.type === "image") {
await pdfReaderRef.current?._pdfDocument.updateWatermark(
watermark.index,
copyWatermark(watermark, {
opacity: 0.65,
scale: 0.5,
rotation: 30,
})
);
}