From d33df9b934ec02cb940031ca60c5231c60ec2855 Mon Sep 17 00:00:00 2001 From: Rishab <33950743+rishabjasrotia@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:49:25 +0530 Subject: [PATCH] Fix Print for mobile --- .../src/Component/component/emailComponent.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/microfrontends/SignDocuments/src/Component/component/emailComponent.js b/microfrontends/SignDocuments/src/Component/component/emailComponent.js index af6ecf0e4..f46bd0060 100644 --- a/microfrontends/SignDocuments/src/Component/component/emailComponent.js +++ b/microfrontends/SignDocuments/src/Component/component/emailComponent.js @@ -109,8 +109,16 @@ function EmailComponent({ const handleToPrint = async (event) => { event.preventDefault(); - const base64 = await getBase64FromUrl(pdfUrl); - printModule({ printable: base64, type: "pdf", base64: true }); + const isAndroidDevice = navigator.userAgent.match(/Android/i); + const isAppleDevice = (/iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) && !window.MSStream + if (isAndroidDevice || isAppleDevice) { + const byteArray = Uint8Array.from(atob(pdf).split('').map(char => char.charCodeAt(0))); + const blob = new Blob([byteArray], { type: 'application/pdf' }); + const blobUrl = URL.createObjectURL(blob); + window.open(blobUrl, '_blank'); + } else { + printModule({ printable: pdf, type: "pdf", base64: true }); + } };