window.onload = function(){
var viewer = new DsPdfViewer("#viewer", getViewerOptions());
configureViewerUI(viewer);
viewer.open("/diodocs/pdfviewer/demos/product-bundles/assets/pdf/sign-with-digital-signature.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>
<script src="./src/config.js"></script>
</head>
<body>
<div id="viewer"></div>
</body>
</html>
#viewer {
height: 100%;
}
function getViewerOptions() {
return {
workerSrc: "/diodocs/pdfviewer/demos/product-bundles/build/dspdfviewer.worker.js",
supportApi: getSupportApiSettings(),
friendlyFileName: "digital-signature-sample.pdf",
restoreViewStateOnLoad: false,
language: "ja"
};
}
function configureViewerUI(viewer) {
viewer.toggleSidebar(false);
viewer.toolbar.addItem({ text: "社員の署名を適用", key: 'employee-signature',
title: '社員の署名を適用する',enabled: false,
action: function() {
const locationName = location.hostname || "不明";
viewer.save(undefined, { sign: { signatureField: "Employee", signerName: "社員名", location: locationName }, reload: true } );
},
onUpdate: function() {
return {
enabled: viewer.hasDocument,
title: '社員の署名を適用する'
};
}
});
viewer.toolbar.addItem({ text: "承認者の署名を適用", key: 'supervisor-signature',
title: '承認者の署名を適用する',enabled: false,
action: function() {
const locationName = location.hostname || "不明";
viewer.save(undefined, { sign: { signatureField: "Supervisor", signerName: "承認者名", location: locationName }, reload: true } );
},
onUpdate: function() {
return {
enabled: viewer.hasDocument,
title: '承認者の署名を適用する'
};
}
});
viewer.toolbarLayout.viewer.mobile = viewer.toolbarLayout.viewer.default = ["employee-signature", "supervisor-signature", "$split", "download", "zoom", "$split", "about"];
}