-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
30 lines (26 loc) · 1.11 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Function to update the recipient's name dynamically
function updateRecipientName() {
const recipientNameElement = document.getElementById('recipientName');
const recipientNameInput = prompt('Enter the recipient\'s name:');
if (recipientNameInput) {
recipientNameElement.textContent = recipientNameInput;
}
}
// Function to generate and download the certificate as a PDF
function downloadCertificate() {
const certificate = document.querySelector('.certificate');
const opt = {
margin: 0,
filename: 'certificate.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2 },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' }
};
html2pdf().from(certificate).set(opt).outputPdf().then((pdf) => {
pdf.save();
});
}
// Event listener to update recipient's name
document.getElementById('generateCertificate').addEventListener('click', updateRecipientName);
// Event listener to generate and download the certificate as PDF
document.getElementById('generateCertificate').addEventListener('click', downloadCertificate);