Download src/utils/pdfGenerator.js from fohake/cert: direct link, hf CLI and curl.
- Browser
- Download file 443 Bytes
-
https://huggingface.co/fohake/cert/resolve/bfdfbb84d48fc9791cb2da254b96bac367fd76a6/src/utils/pdfGenerator.js
- Command line
-
hf download hf://fohake/cert@bfdfbb84d48fc9791cb2da254b96bac367fd76a6/src/utils/pdfGenerator.js
-
curl -L -o pdfGenerator.js https://huggingface.co/fohake/cert/resolve/bfdfbb84d48fc9791cb2da254b96bac367fd76a6/src/utils/pdfGenerator.js
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'); | |
| }; |