fixed error - building image

This commit is contained in:
pramod.mahajan 2025-11-08 15:34:59 +05:30
parent 0dac797e21
commit 04806c6d53

View File

@ -68,38 +68,7 @@ const Invoice = ({ invoiceData, currencySymbol }) => {
};
const downloadPDF = async () => {
setIsGenerating(true);
try {
const invoice = invoiceRef.current;
const canvas = await html2canvas(invoice, {
scale: 2,
useCORS: true,
logging: false,
backgroundColor: "#ffffff",
});
const imgData = canvas.toDataURL("image/png");
const pdf = new jsPDF({
orientation: "portrait",
unit: "mm",
format: "a4",
});
const imgWidth = 210;
const pageHeight = 297;
const imgHeight = (canvas.height * imgWidth) / canvas.width;
pdf.addImage(imgData, "PNG", 0, 0, imgWidth, imgHeight);
const paymentId = data.razorpayPaymentDetails.paymentId;
pdf.save(`Invoice_${paymentId}.pdf`);
} catch (error) {
console.error("Error generating PDF:", error);
alert("Failed to generate PDF. Please try again.");
} finally {
setIsGenerating(false);
}
alert("Under the woking");
};
const payment = data.razorpayPaymentDetails;