Skip to content

Commit 0ebdfff

Browse files
Merge pull request #1374 from OpenSignLabs/validation
fix: widgets get removed from doc when signers try to sign at a time
2 parents 1e13b50 + ed840f3 commit 0ebdfff

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

apps/OpenSign/src/pages/PdfRequestFiles.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,9 +891,29 @@ function PdfRequestFiles(props) {
891891
setIsUiLoading(true);
892892
// `widgets` is Used to return widgets details with page number of current user
893893
const widgets = checkUser?.[0]?.placeHolder;
894-
894+
let pdfArrBuffer;
895+
//`contractDocument` function used to get updated SignedUrl
896+
// to resolve issue of widgets get remove automatically when more than 1 signers try to sign doc at a time
897+
const documentData = await contractDocument(documentId);
898+
if (documentData && documentData.length > 0) {
899+
const url = documentData[0]?.SignedUrl || documentData[0]?.URL;
900+
//convert document url in array buffer format to use embed widgets in pdf using pdf-lib
901+
const arrayBuffer = await convertPdfArrayBuffer(url);
902+
if (arrayBuffer === "Error") {
903+
setHandleError("Error: invalid document!");
904+
} else {
905+
pdfArrBuffer = arrayBuffer;
906+
}
907+
} else if (
908+
documentData === "Error: Something went wrong!" ||
909+
(documentData.result && documentData.result.error)
910+
) {
911+
setHandleError("Error: Something went wrong!");
912+
} else {
913+
setHandleError("Document not Found!");
914+
}
895915
// Load a PDFDocument from the existing PDF bytes
896-
const existingPdfBytes = pdfArrayBuffer;
916+
const existingPdfBytes = pdfArrBuffer;
897917
try {
898918
const pdfDoc = await PDFDocument.load(existingPdfBytes);
899919
const isSignYourSelfFlow = false;

0 commit comments

Comments
 (0)