<script type="text/javascript" src="https://cdn.lacunasoftware.com/libs/web-pki/lacuna-web-pki-2.16.4.min.js"
integrity="sha256-/ewfOhYUupiYfA543JeLqCgjdwVmHW+JQDc0bFTm3MQ="
crossorigin="anonymous"></script>
<h2>Web PKI - Local PDF Signature</h2>
<h4>Serial signature sample with PDF passed from JavasSript and signed PDF returned to JavasSript</h4>
<p>Select a certificate:
<br/>
<select id="certificateSelect"></select>
</p>
<p>
<button id="refreshButton" type="button">Refresh Certificates</button>
</p>
<p>
<button id="signPadesButton" type="button">Sign PDF</button>
<button id="signPadesAgainButton" type="button">Sign PDF Again</button>
</p>
<p>Signed PDF content:</p>
<textarea id="contentResult" rows="8" cols="100"></textarea>
<p>
<a id="downloadPdfLink" href='#' download="signed.pdf">Download Signed PDF</a>
</p>
<h4>Logs:</h4>
<div id="logPanel"></div>
// ------------------------------------------------------------------------------------------
// LacunaWebPKI: Local PDF Signature
// Serial signature sample with PDF passed from JavasSript and signed PDF returned to JavasSript
var pdfContentSample = null;
var signedPdfContent = null;
var pki = new LacunaWebPKI('AiEAKi5sYWN1bmFzb2Z0d2FyZS5jb20sanNmaWRkbGUubmV0AAADAFBybwgAABg/D+l74AgAAVP0dSRjd5vjlQ8EFzCfN2tOR/S2ENB6x1vRXssle+wxvbEeT3/vmzm7eKDMWr8kgl2W/BfUqYCOC0PnLOVKS8Em0OXtYD+F3WI1+3zQcvI2W34ppGVx1zizoRfyq+Q4KZ9rZPtFYyoBmr1SR5ZyWPqXWNY7p5XWFkxvFmQU11jho5Cd8VX6cv2OuOEw4eBptN5whzV+9XPHEmPav+TJB0hsYbw0TzwLC253i8WhJEQyIVenNGNNHT3foxsFmDTvXqF/HgjOwqgyJJ1hL0wIqsN0pB5weYhjGLwlRt1FqLV1xTScs5nP3xWTK/CPBpq3NDdTobQMsc7PEF46RT1qXbg=');
function start() {
log('Initializing component');
pki.init({
ready: onWebPkiReady,
defaultFail: onWebPkiError,
requiredApiVersion: pki.apiVersions.v1_5_2
});
}
function onWebPkiReady() {
refreshCertificates();
}
function onWebPkiError(ex) {
log('Error: ' + ex.userMessage + ' (' + ex.code + ')');
}
// ------------------------------------------
function refreshCertificates() {
log('Listing certificates');
pki.listCertificates({
selectId: 'certificateSelect'
}).success(function(certs) {
log(certs.length + ' certificates found');
});
}
// ------------------------------------------
function signPades() {
// get selected certificate thumbprint
var selectedCertThumb = $('#certificateSelect').val();
if (!selectedCertThumb) {
alert('Select a certificate!');
return;
}
// clear result box
$('#contentResult').val('');
log('Signing PDF content...');
pki.signPdf({
content: pdfContentSample, // PDf to sign base64 encoded
output: {
mode: pki.outputModes.returnContent // return signed PDF to page
},
certificateThumbprint: selectedCertThumb,
policy: pki.padesPolicies.basic,
trustArbitrators:...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.