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" } },
"フィールドの署名:"));
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}、署名者:${signerName}、場所:${location}、日付:${signDate}`));
}
s = "ドキュメントはデジタル署名を使用して署名済みです。";
} else {
s = "ドキュメントには署名がありません。";
}
if(signatureInfo.signatureFields.length === 0) {
detailsJsx.push(React.createElement("h4", { style: { padding: "0 2px 0px 3px", margin: "0" } },
"署名フィールドはありません。"));
} else {
detailsJsx.push(React.createElement("h4", { style: { padding: "0 2px 0px 3px", margin: "0" } },
"すべての署名フィールド:"));
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", {restoreViewStateOnLoad: false, language: "ja"});
configureViewerUI(viewer);
viewer.open("/diodocs/pdfviewer/demos/product-bundles/assets/pdf/signature-info.pdf");
}
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>デジタル署名情報の表示</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./src/styles.css">
<script src="/diodocs/pdfviewer/demos/product-bundles/build/dspdfviewer.js"></script>
<script src="/diodocs/pdfviewer/demos/product-bundles/build/wasmSupportApi.js"></script>
<script src="/diodocs/pdfviewer/demos/resource/js/init.js"></script>
<script src="./src/app.js"></script>
</head>
<body>
<div id="viewer"></div>
</body>
</html>
#viewer {
height: 100%;
}