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

Function signPdfFun

apps/OpenSign/src/pages/SignyourselfPdf.jsx:759–813  ·  view source on GitHub ↗
(base64Url, documentId)

Source from the content-addressed store, hash-verified

757 }
758 //function for get digital signature
759 const signPdfFun = async (base64Url, documentId) => {
760 let isCustomCompletionMail = false;
761 const tenantDetails = await getTenantDetails(jsonSender.objectId);
762 if (tenantDetails && tenantDetails === "user does not exist!") {
763 alert(t("user-not-exist"));
764 } else {
765 if (
766 tenantDetails?.CompletionBody &&
767 tenantDetails?.CompletionSubject
768 ) {
769 isCustomCompletionMail = true;
770 }
771 }
772 // below for loop is used to get first signature of user to send if to signpdf
773 // for adding it in completion certificate
774 let getSignature;
775 for (let item of xyPosition) {
776 if (!getSignature) {
777 const typeExist = item.pos.some((data) => data?.type);
778 if (typeExist) {
779 getSignature = item.pos.find((data) => data?.type === "signature");
780 } else {
781 getSignature = item.pos.find((data) => !data.isStamp);
782 }
783 }
784 }
785 let base64Sign = getSignature.SignUrl;
786 //check https type signature (default signature exist) then convert in base64
787 const isUrl = base64Sign.includes("https");
788 if (isUrl) {
789 try {
790 base64Sign = await fetchImageBase64(base64Sign);
791 } catch (e) {
792 console.log("error", e);
793 alert(t("something-went-wrong-mssg"));
794 }
795 }
796 //change image width and height to 300/120 in png base64
797 const imagebase64 = await changeImageWH(base64Sign);
798 //remove suffiix of base64 (without type)
799 const suffixbase64 = imagebase64 && imagebase64.split(",").pop();
800 const params = {
801 pdfFile: base64Url,
802 docId: documentId,
803 isCustomCompletionMail: isCustomCompletionMail,
804 signature: suffixbase64,
805 };
806 const resSignPdf = await Parse.Cloud.run("signPdf", params);
807 if (resSignPdf) {
808 const signedpdf = JSON.parse(JSON.stringify(resSignPdf));
809 setPdfUrl(signedpdf);
810 dispatch(setTypedSignFont("Fasthand"));
811 getDocumentDetails(false);
812 }
813 };
814 //function for save x and y position and show signature tab on that position
815 const handleTabDrag = (key) => {
816 setDragKey(key);

Callers 1

embedWidgetsDataFunction · 0.70

Calls 4

getTenantDetailsFunction · 0.90
fetchImageBase64Function · 0.90
changeImageWHFunction · 0.90
getDocumentDetailsFunction · 0.70

Tested by

no test coverage detected