Skip to content

Commit d4be4ae

Browse files
Merge pull request #143 from rishabjasrotia/issue/81
2 parents c736bbc + 4caf7b8 commit d4be4ae

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

microfrontends/SignDocuments/src/Component/component/emailComponent.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,17 @@ function EmailComponent({
109109
const handleToPrint = async (event) => {
110110
event.preventDefault();
111111

112-
const base64 = await getBase64FromUrl(pdfUrl);
113-
printModule({ printable: base64, type: "pdf", base64: true });
112+
const pdf = await getBase64FromUrl(pdfUrl);
113+
const isAndroidDevice = navigator.userAgent.match(/Android/i);
114+
const isAppleDevice = (/iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) && !window.MSStream
115+
if (isAndroidDevice || isAppleDevice) {
116+
const byteArray = Uint8Array.from(atob(pdf).split('').map(char => char.charCodeAt(0)));
117+
const blob = new Blob([byteArray], { type: 'application/pdf' });
118+
const blobUrl = URL.createObjectURL(blob);
119+
window.open(blobUrl, '_blank');
120+
} else {
121+
printModule({ printable: pdf, type: "pdf", base64: true });
122+
}
114123

115124
};
116125

microfrontends/SignDocuments/src/Component/component/header.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,16 @@ function Header({
6060
event.preventDefault();
6161

6262
const pdf = await getBase64FromUrl(pdfUrl);
63-
64-
printModule({ printable: pdf, type: "pdf", base64: true });
63+
const isAndroidDevice = navigator.userAgent.match(/Android/i);
64+
const isAppleDevice = (/iPad|iPhone|iPod/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) && !window.MSStream
65+
if (isAndroidDevice || isAppleDevice) {
66+
const byteArray = Uint8Array.from(atob(pdf).split('').map(char => char.charCodeAt(0)));
67+
const blob = new Blob([byteArray], { type: 'application/pdf' });
68+
const blobUrl = URL.createObjectURL(blob);
69+
window.open(blobUrl, '_blank');
70+
} else {
71+
printModule({ printable: pdf, type: "pdf", base64: true });
72+
}
6573
};
6674

6775
//handle download signed pdf

0 commit comments

Comments
 (0)