Professional Documents
Culture Documents
Wsjs
Wsjs
Wsjs
js initialization
pdfjsLib.GlobalWorkerOptions.workerSrc =
'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.8.335/pdf.worker.min.js';
// Create an image element with the watermark and append it to the PDF
container
const watermarkImage = new Image();
watermarkImage.src = imageDataUrl;
document.getElementById('pdfContainer').appendChild(watermarkImage);
});
});
});
}
// Fetch the PDF file and add watermark when the document is ready
document.addEventListener('DOMContentLoaded', function () {
// Replace 'example.pdf' with the URL or path to your PDF file
fetch('example.pdf')
.then(response => response.arrayBuffer())
.then(arrayBuffer => addWatermarkToPDF(new Uint8Array(arrayBuffer)));
});