function configureViewerUI(viewer) {
var React = viewer.getType("React");
viewer.addDefaultPanels();
viewer.onAfterOpen.register(function() {
viewer.getSignatureInfo().then(function (signatureInfo) {
let s = "";
const detailsJsx = [];
if(signatureInfo.signed) {
detailsJsx.push(React.createElement("h4", { style: { padding: "0 2px 0px 3px", margin: "0" } },
"SIGNED BY FIELDS:"));
for(let i = 0; i < signatureInfo.signedByFields.length; i++) {
const signedField = signatureInfo.signedByFields[i], signatureValue = signedField.signatureValue,
signerName = signatureValue.name, location = signatureValue.location,
signDate = viewer.pdfStringToDate(signatureValue.modificationDate).toDateString();
detailsJsx.push(React.createElement("p", { style: { padding: "0 10px 4px 10px", margin: "0" } },
`• ${signedField.fieldName}, signer: ${signerName}, location: ${location}, date: ${signDate}.`));
}
s = "The document was signed using digital signature.";
} else {
s = "The document is not signed.";
}
if(signatureInfo.signatureFields.length === 0) {
detailsJsx.push(React.createElement("h4", { style: { padding: "0 2px 0px 3px", margin: "0" } },
"NO SIGNATURE FIELDS."));
} else {
detailsJsx.push(React.createElement("h4", { style: { padding: "0 2px 0px 3px", margin: "0" } },
"ALL SIGNATURE FIELDS:"));
for(const field of signatureInfo.signatureFields) {
detailsJsx.push(React.createElement("span", { style: { padding: "0 2px 0px 10px", margin: "0" } },
`'${field.fieldName}'; `));
}
}
viewer.showMessage(s, detailsJsx);
});
});
}
window.onload = function() {
var viewer = new DsPdfViewer("#viewer");
configureViewerUI(viewer);
viewer.open("/document-solutions/javascript-pdf-viewer/demos/product-bundles/assets/pdf/signature-info.pdf");
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Check if document signed</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./src/styles.css">
<script src="/document-solutions/javascript-pdf-viewer/demos/product-bundles/build/dspdfviewer.js"></script>
<script src="/document-solutions/javascript-pdf-viewer/demos/product-bundles/build/wasmSupportApi.js"></script>
<script src="/document-solutions/javascript-pdf-viewer/demos/resource/js/init.js"></script>
<script src="./src/app.js"></script>
</head>
<body>
<div id="viewer"></div>
</body>
</html>
#viewer {
height: 100%;
}