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 getWatermarkCount() to get the number of watermarks in the document.
const count = await pdfReaderRef.current?._pdfDocument.getWatermarkCount();
console.log("Watermark count:", count);Use getWatermark() to get a specific watermark by index:
const watermark = await pdfReaderRef.current?._pdfDocument.getWatermark(0);
if (watermark) {
console.log("Type:", watermark.type);
console.log("Pages:", watermark.pages);
console.log("Opacity:", watermark.opacity);
}Use getWatermarks() to get all watermarks:
const watermarks = await pdfReaderRef.current?._pdfDocument.getWatermarks();
watermarks?.forEach((watermark) => {
console.log(`#${watermark.index}: ${watermark.type}`);
});Export Image Watermark Content
When getting image watermark information, imagePath is empty by default. Set exportImage or exportImages to true to export the image watermark bitmap to a temporary local file.
const watermark = await pdfReaderRef.current?._pdfDocument.getWatermark(0, {
exportImage: true,
});
if (watermark?.isImageExported) {
console.log("Exported image path:", watermark.imagePath);
}To export images for all watermarks:
const watermarks = await pdfReaderRef.current?._pdfDocument.getWatermarks({
exportImages: true,
});Exported image paths point to SDK-managed temporary or cache files. If your app needs to keep an image, copy it to an app-managed location.