cert / src /utils /pdfGenerator.js
fohake's picture
Upload 14 files
78dd0bb verified
raw
history blame contribute delete
443 Bytes
import html2canvas from 'html2canvas';
import { jsPDF } from 'jspdf';
export const generatePDF = async (container) => {
const canvas = await html2canvas(container);
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF({
orientation: 'landscape',
unit: 'px',
format: [canvas.width, canvas.height]
});
pdf.addImage(imgData, 'PNG', 0, 0, canvas.width, canvas.height);
pdf.save('certificate.pdf');
};