diff --git a/src/Pages/BookingScreen/Components/BookingFunctionality/MobilePdfPrint.js b/src/Pages/BookingScreen/Components/BookingFunctionality/MobilePdfPrint.js index 28d888b..287c6ba 100644 --- a/src/Pages/BookingScreen/Components/BookingFunctionality/MobilePdfPrint.js +++ b/src/Pages/BookingScreen/Components/BookingFunctionality/MobilePdfPrint.js @@ -2,6 +2,7 @@ import { blobToBase64,encryptObject, pdfDiv } from "../../../../Services/Others" import { PrintStyleFunction } from "../../../paymentpdfPage/PrintStyleFunction"; import { Emailsend } from "../../../../Features/PurchaseOrder/PurchaseOrder"; import { PublicQrCodepost } from "../../../../Features/ConfigMasterPage/ConfigMasterPage"; +import { downloadFile } from "../../../../utils/downloadFile"; const MainHomeUrl = import.meta.env.ENV_MAIN_BASE_URL; export const MobilePdfPrint = async ({ printerTemplateStyle = 'Style 13', @@ -111,14 +112,26 @@ export const MobilePdfPrint = async ({ if (PrintComing === 'download') { // 📥 Download PDF - const link = document.createElement('a'); - link.href = URL.createObjectURL(pdfBlob); - link.download = `Receipt_${new Date().getTime()}.pdf`; - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - URL.revokeObjectURL(link.href); - + // const link = document.createElement('a'); + // link.href = URL.createObjectURL(pdfBlob); + // link.download = `Receipt_${new Date().getTime()}.pdf`; + // document.body.appendChild(link); + // link.click(); + // document.body.removeChild(link); + // URL.revokeObjectURL(link.href); + const buffer = await pdfBlob.arrayBuffer(); + + downloadFile( + buffer, + `Receipt_${new Date().getTime()}.pdf`, + "application/pdf", + (success) => { + if (!success) { + + console.error('Failed to download the file. Please try again.'); + } + } + ); // Clear printed orders setPrintOrderDetails([]); return; diff --git a/src/Pages/Reports/LedgerReport/LedgerReport.jsx b/src/Pages/Reports/LedgerReport/LedgerReport.jsx index 09999ad..6c86205 100644 --- a/src/Pages/Reports/LedgerReport/LedgerReport.jsx +++ b/src/Pages/Reports/LedgerReport/LedgerReport.jsx @@ -34,6 +34,7 @@ import { useSelector } from 'react-redux'; import excelExport from '../../../Images/xls-export.png'; import ExcelJS from 'exceljs'; import { saveAs } from 'file-saver'; +import { downloadFile } from '../../../utils/downloadFile.js'; dayjs.extend(customParseFormat); @@ -620,8 +621,19 @@ const LedgerReport = () => { hours = String(hours).padStart(2, '0'); const fileName = `Ledger Report_${day}-${month}-${year}_${hours}-${minutes}-${ampm}.xlsx`; - - saveAs(blob, fileName); + downloadFile( + buffer, + fileName, + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + (success) => { + if (success) { + console.log("File downloaded and opened successfully!"); + } else { + console.log("Failed to download/open file."); + } + } + ); + // saveAs(blob, fileName); }; const FirstOrderLedgerDateRaw = dayjs(FirstOrderLedgerDate);