🔥 The free & Open Source DocuSign alternative
JavaScript digital-signaturedocument-signingdocusign-alternativedocusign-freee-signatureelectronic-signatureelectronic-signaturesesignesignaturehacktoberfestjavascriptlegaltechmongodbnodejsopen-sourcepdf-signpdf-signaturereactjsself-hostedsign-pdf-files
fix: issue of showing currently incrypted file not supported when try to sign document
prafull-opensignlabs07382822bd91
diff --git a/apps/OpenSign/src/components/pdf/SignPad.js b/apps/OpenSign/src/components/pdf/SignPad.jsindex 9103a3d8f..3fd03328a 100644--- a/apps/OpenSign/src/components/pdf/SignPad.js+++ b/apps/OpenSign/src/components/pdf/SignPad.js@@ -214,8 +214,8 @@ function SignPad({const fontfamily = fontStyle? fontStyle: fontSelect- ? fontSelect- : "Fasthand";+ ? fontSelect+ : "Fasthand";//creating span for getting text content widthconst span = document.createElement("span");@@ -267,10 +267,10 @@ function SignPad({key === 0 && penColor === "blue"? "2px solid blue": key === 1 && penColor === "red"- ? "2px solid red"- : key === 2 && penColor === "black"- ? "2px solid black"- : "2px solid white"+ ? "2px solid red"+ : key === 2 && penColor === "black"+ ? "2px solid black"+ : "2px solid white"}}onClick={() => {props?.convertToImg &&@@ -536,7 +536,6 @@ function SignPad({style={{border: "1.3px solid #007bff",borderRadius: "2px",-display: "flex",flexDirection: "column",justifyContent: "center",@@ -553,7 +552,7 @@ function SignPad({type="file"onChange={onImageChange}className="filetype"- accept="image/*"+ accept="image/png,image/jpeg"ref={imageRef}hidden/>diff --git a/apps/OpenSign/src/constant/Utils.js b/apps/OpenSign/src/constant/Utils.jsindex 63289af0b..f342dff8d 100644--- a/apps/OpenSign/src/constant/Utils.js+++ b/apps/OpenSign/src/constant/Utils.js@@ -561,17 +561,22 @@ export const signPdfFun = async (isCustomCompletionMail = true;}}-++ // below for loop is used to get first signature of user to send if to signpdf+ // for adding it in completion certificatelet getSignature;for (let item of xyPosition) {const typeExist = item.pos.some((data) => data?.type);if (typeExist) {- getSignature = item.pos.filter((data) => data?.type === "signature");+ getSignature = item.pos.find((data) => data?.type === "signature");+ break;} else {- getSignature = item.pos.filter((data) => !data.isStamp);+ getSignature = item.pos.find((data) => !data.isStamp);+ break;}}- let base64Sign = getSignature[0].SignUrl;++ let base64Sign = getSignature.SignUrl;//check https type signature (default signature exist) then convert in base64const isUrl = base64Sign.includes("https");if (isUrl) {@@ -1344,8 +1349,8 @@ export const multiSignEmbed = async (position.type === radioButtonWidget? 10: position.type === "checkbox"- ? 10- : newUpdateHeight;+ ? 10+ : newUpdateHeight;const newHeight = ind ? (ind > 0 ? widgetHeight : 0) : widgetHeight;if (signyourself) {diff --git a/apps/OpenSign/src/pages/PdfRequestFiles.js b/apps/OpenSign/src/pages/PdfRequestFiles.jsindex 0eb54aeb0..b7f6384b1 100644--- a/apps/OpenSign/src/pages/PdfRequestFiles.js+++ b/apps/OpenSign/src/pages/PdfRequestFiles.js@@ -647,7 +647,6 @@ function PdfRequestFiles() {const existingPdfBytes = pdfArrayBuffer;try {const pdfDoc = await PDFDocument.load(existingPdfBytes);-const isSignYourSelfFlow = false;const extUserPtr = pdfDetails[0].ExtUserPtr;const HeaderDocId = extUserPtr?.HeaderDocId;@@ -843,10 +842,18 @@ function PdfRequestFiles() {}} catch (err) {setIsUiLoading(false);- setIsAlert({- isShow: true,- alertMessage: `Currently encrypted pdf files are not supported.`- });+ if (err && err.message.includes("is encrypted.")) {+ setIsAlert({+ isShow: true,+ alertMessage: `Currently encrypted pdf files are not supported.`+ });+ } else {+ console.log("err in request signing", err);+ setIsAlert({+ isShow: true,+ alertMessage: `Something went wrong.`+ });+ }}}setIsSignPad(false);@@ -1238,9 +1245,9 @@ function PdfRequestFiles() {isDecline.currnt === "Sure"? "Are you sure want to decline this document ?": isDecline.currnt === "YouDeclined"- ? "You have declined this document!"- : isDecline.currnt === "another" &&- "You can not sign this document as it has been declined/revoked."+ ? "You have declined this document!"+ : isDecline.currnt === "another" &&+ "You can not sign this document as it has been declined/revoked."}footerMessage={isDecline.currnt === "Sure"}declineDoc={declineDoc}diff --git a/apps/OpenSign/src/pages/SignyourselfPdf.js b/apps/OpenSign/src/pages/SignyourselfPdf.jsindex 6ad106d93..7fe144910 100644--- a/apps/OpenSign/src/pages/SignyourselfPdf.js+++ b/apps/OpenSign/src/pages/SignyourselfPdf.js@@ -480,13 +480,13 @@ function SignYourSelf() {Width: widgetTypeExist? calculateInitialWidthHeight(dragTypeValue, widgetValue).getWidth: dragTypeValue === "initials"- ? defaultWidthHeight(dragTypeValue).width- : "",+ ? defaultWidthHeight(dragTypeValue).width+ : "",Height: widgetTypeExist? calculateInitialWidthHeight(dragTypeValue, widgetValue).getHeight: dragTypeValue === "initials"- ? defaultWidthHeight(dragTypeValue).height- : "",+ ? defaultWidthHeight(dragTypeValue).height+ : "",options: addWidgetOptions(dragTypeValue)};@@ -649,9 +649,7 @@ function SignYourSelf() {const existingPdfBytes = pdfArrayBuffer;// Load a PDFDocument from the existing PDF bytestry {- const pdfDoc = await PDFDocument.load(existingPdfBytes, {- ignoreEncryption: true- });+ const pdfDoc = await PDFDocument.load(existingPdfBytes);const isSignYourSelfFlow = true;const extUserPtr = pdfDetails[0].ExtUserPtr;const HeaderDocId = extUserPtr?.HeaderDocId;@@ -672,10 +670,18 @@ function SignYourSelf() {await signPdfFun(pdfBytes, documentId);} catch (err) {setIsUiLoading(false);- setIsAlert({- isShow: true,- alertMessage: `Currently encrypted pdf files are not supported.`- });+ if (err && err.message.includes("is encrypted.")) {+ setIsAlert({+ isShow: true,+ alertMessage: `Currently encrypted pdf files are not supported.`+ });+ } else {+ console.log("err in signing", err);+ setIsAlert({+ isShow: true,+ alertMessage: `Something went wrong.`+ });+ }}}} catch (err) {@@ -703,16 +709,20 @@ function SignYourSelf() {isCustomCompletionMail = true;}}+ // below for loop is used to get first signature of user to send if to signpdf+ // for adding it in completion certificatelet getSignature;for (let item of xyPostion) {const typeExist = item.pos.some((data) => data?.type);if (typeExist) {- getSignature = item.pos.filter((data) => data?.type === "signature");+ getSignature = item.pos.find((data) => data?.type === "signature");+ break;} else {- getSignature = item.pos.filter((data) => !data.isStamp);+ getSignature = item.pos.find((data) => !data.isStamp);+ break;}}- let base64Sign = getSignature[0].SignUrl;+ let base64Sign = getSignature.SignUrl;//check https type signature (default signature exist) then convert in base64const isUrl = base64Sign.includes("https");if (isUrl) {