(event, setIsDownloading, pdfDetails)
| 3050 | } |
| 3051 | //function for print digital sign pdf |
| 3052 | export const handleToPrint = async (event, setIsDownloading, pdfDetails) => { |
| 3053 | event.preventDefault(); |
| 3054 | setIsDownloading("pdf"); |
| 3055 | const pdfUrl = pdfDetails?.[0]?.SignedUrl || pdfDetails?.[0]?.URL; |
| 3056 | const docId = pdfDetails?.[0]?.objectId || ""; |
| 3057 | |
| 3058 | try { |
| 3059 | // const url = await Parse.Cloud.run("getsignedurl", { url: pdfUrl }); |
| 3060 | //`localStorage.getItem("baseUrl")` is also use in public-profile flow for public-sign |
| 3061 | //if we give this `appInfo.baseUrl` as a base url then in public-profile it will create base url of it's window.location.origin ex- opensign.me which is not base url |
| 3062 | const axiosRes = await axios.post( |
| 3063 | `${localStorage.getItem("baseUrl")}/functions/getsignedurl`, |
| 3064 | { |
| 3065 | url: pdfUrl, |
| 3066 | docId: docId |
| 3067 | }, |
| 3068 | { |
| 3069 | headers: { |
| 3070 | "content-type": "Application/json", |
| 3071 | "X-Parse-Application-Id": localStorage.getItem("parseAppId"), |
| 3072 | "X-Parse-Session-Token": localStorage.getItem("accesstoken") |
| 3073 | } |
| 3074 | } |
| 3075 | ); |
| 3076 | const url = axiosRes.data.result; |
| 3077 | const pdf = await getBase64FromUrl(url); |
| 3078 | const isAndroidDevice = navigator.userAgent.match(/Android/i); |
| 3079 | const isAppleDevice = |
| 3080 | (/iPad|iPhone|iPod/.test(navigator.platform) || |
| 3081 | (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1)) && |
| 3082 | !window.MSStream; |
| 3083 | if (isAndroidDevice || isAppleDevice) { |
| 3084 | const byteArray = Uint8Array.from( |
| 3085 | atob(pdf) |
| 3086 | .split("") |
| 3087 | .map((char) => char.charCodeAt(0)) |
| 3088 | ); |
| 3089 | const blob = new Blob([byteArray], { type: "application/pdf" }); |
| 3090 | const blobUrl = URL.createObjectURL(blob); |
| 3091 | window.open(blobUrl, "_blank"); |
| 3092 | setIsDownloading(""); |
| 3093 | } else { |
| 3094 | printModule({ printable: pdf, type: "pdf", base64: true }); |
| 3095 | setIsDownloading(""); |
| 3096 | } |
| 3097 | } catch (err) { |
| 3098 | setIsDownloading(""); |
| 3099 | console.log("err in getsignedurl", err); |
| 3100 | alert(i18n.t("something-went-wrong-mssg")); |
| 3101 | } |
| 3102 | }; |
| 3103 | const downloadCertificate = async (certificate, isZip, asBlob) => { |
| 3104 | try { |
| 3105 | const appName = "OpenSign™"; |
no test coverage detected