MCPcopy Index your code
hub / github.com/OpenSignLabs/OpenSign / fetchBase64

Function fetchBase64

apps/OpenSign/src/constant/Utils.js:2989–3010  ·  view source on GitHub ↗
(pdfBase64, pdfName)

Source from the content-addressed store, hash-verified

2987};
2988//download base64 type pdf
2989export const fetchBase64 = async (pdfBase64, pdfName) => {
2990 // Create a Blob from the Base64 string
2991 const byteCharacters = atob(pdfBase64);
2992 const byteNumbers = new Array(byteCharacters.length)
2993 .fill(0)
2994 .map((_, i) => byteCharacters.charCodeAt(i));
2995 const byteArray = new Uint8Array(byteNumbers);
2996 const blob = new Blob([byteArray], { type: "application/pdf" });
2997
2998 // Create a link element
2999 const link = document.createElement("a");
3000 link.href = URL.createObjectURL(blob);
3001 link.download = pdfName;
3002
3003 // Programmatically click the link to trigger the download
3004 document.body.appendChild(link);
3005 link.click();
3006
3007 // Clean up
3008 document.body.removeChild(link);
3009 URL.revokeObjectURL(link.href);
3010};
3011//handle download signed pdf
3012export const handleDownloadPdf = async (
3013 pdfDetails,

Callers 1

handleDownloadPdfFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected