import { jsPDF } from "jspdf"; import "jspdf/dist/polyfills.es.js"; import { regex } from "./constant"; const htmlPdfConverter = (basicDetails, inputs) => { const pdfHeading = ` <div class="h-full w-full text-dream_vacation block justify-center items-end"> <div class="w-full flex justify-end h-full"> <img src=${window.location.origin + "/indiafirst-color.png"} alt="" class="h-[110px] w-[130px]" /> </div> <div class="w-full mb-4 mt-2 h-20 font-semibold text-[38px] text-center"> Future Wealth Creation Report </div> </div> `; const date = new Date(); const doc = new jsPDF(); doc.setFontSize(12); doc.setProperties({ title: "Future Wealth Creation Report", subject: "Future Wealth Creation Report", author: "India first life", keywords: "generated, javascript, web 2.0, ajax", creator: "India first life" }); doc.html(pdfHeading, { useCORS: true, pageSplit: true, callback: function (pdf) { pdf.save( `Wealth Creation Calculator Report_${ date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear() }.pdf` ); }, margin: [10, 10, 10, 10], autoPaging: "text", x: 0, y: 0, width: 195, windowWidth: 900 }); return true; }; export default htmlPdfConverter;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter