From b97ad9c2e02ff13b980642aaecc276242506ad61 Mon Sep 17 00:00:00 2001 From: prafull-opensignlabs Date: Tue, 22 Oct 2024 19:44:21 +0530 Subject: [PATCH] fix: widgets get removed from doc when signers try to sign at a time --- apps/OpenSign/src/pages/PdfRequestFiles.js | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/apps/OpenSign/src/pages/PdfRequestFiles.js b/apps/OpenSign/src/pages/PdfRequestFiles.js index 324cb8bc6..7ee601129 100644 --- a/apps/OpenSign/src/pages/PdfRequestFiles.js +++ b/apps/OpenSign/src/pages/PdfRequestFiles.js @@ -891,9 +891,29 @@ function PdfRequestFiles(props) { setIsUiLoading(true); // `widgets` is Used to return widgets details with page number of current user const widgets = checkUser?.[0]?.placeHolder; - + let pdfArrBuffer; + //`contractDocument` function used to get updated SignedUrl + // to resolve issue of widgets get remove automatically when more than 1 signers try to sign doc at a time + const documentData = await contractDocument(documentId); + if (documentData && documentData.length > 0) { + const url = documentData[0]?.SignedUrl || documentData[0]?.URL; + //convert document url in array buffer format to use embed widgets in pdf using pdf-lib + const arrayBuffer = await convertPdfArrayBuffer(url); + if (arrayBuffer === "Error") { + setHandleError("Error: invalid document!"); + } else { + pdfArrBuffer = arrayBuffer; + } + } else if ( + documentData === "Error: Something went wrong!" || + (documentData.result && documentData.result.error) + ) { + setHandleError("Error: Something went wrong!"); + } else { + setHandleError("Document not Found!"); + } // Load a PDFDocument from the existing PDF bytes - const existingPdfBytes = pdfArrayBuffer; + const existingPdfBytes = pdfArrBuffer; try { const pdfDoc = await PDFDocument.load(existingPdfBytes); const isSignYourSelfFlow = false;