<script type="text/javascript" src="https://cdn.lacunasoftware.com/libs/web-pki/lacuna-web-pki-2.13.0.min.js" integrity="sha256-nVy9sLakeQ03Xl+jOjBdjdfnZ9UVwwqNgAYszhxi4VQ=" crossorigin="anonymous"></script>
<h2>Web PKI - Local PDF Signature</h2>
<h4>Signature from local computer PDF file and signed PDF saved in the same directory with suffix '-signed'</h4>
<p>Select a certificate:
<br/>
<select id="certificateSelect"></select>
</p>
<p>
<button id="refreshButton" type="button">Refresh Certificates</button>
</p>
<p>
<button id="selectFile" type="button">Select a PDF file</button>
<span id="selectedFileName"> !!!! </span>
</p>
<br/>
<p>
<button id="signPadesButton" type="button">Sign PDF</button>
</p>
<p> Signed Files:</p>
<div id="signedFilesPanel"></div>
<br/>
<h4>Logs:</h4>
<div id="logPanel"></div>
// ------------------------------------------------------------------------------------------
// LacunaWebPKI: Local PDF Signature
// Signature from local computer PDF file and signed PDF saved in the same directory with suffix '-signed'
var pdfFileInfo = null;
var signedPdfFileInfo = 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
});
}
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;
}
signedPdfFileInfo = null;
log('Signing PDF file...');
pki.signPdf({
fileId: pdfFileInfo.id,
output: {
mode: pki.outputModes.showSaveFileDialog,
dialogTitle: 'Selecione o destino do arquivo'
},
certificateThumbprint: selectedCertThumb,
policy: pki.padesPolicies.basic,
trustArbitrators: [pki.standardTrustArbitrators.pkiBrazil],
certificateValidationLevel:...
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.