Signer Cookbook
Creating a Signature
import {nopodofo as npdf, NPDFAnnotationFlag, NPDFAnnotation, pdfDate} from 'nopodofo'
const doc = new npdf.Document()
doc.load('/path/to/pdf', e => {
if(e) {}
const rect = new npdf.Rect(400, 685, 50, 20),
page = doc.getPage(0),
annot = page.createAnnotation(NPDFAnnotation.Widget, rect)
annot.flags = NPDFAnnotationFlag.Hidden | NPDFAnnotationFlag.Invisible
annot.flags = NPDFAnnotation.Print
const image = new nopodofo.Image(doc, join(__dirname, '../test-documents/signatureImage.jpg'))
const painter = new nopodofo.Painter(doc)
painter.setPage(page)
painter.drawImage(image, rect.left, rect.bottom, {width: rect.width, height: rect.height})
painter.finishPage();
const field = new npdf.SignatureField(annot, doc)
field.setReason('test')
field.setLocation('here')
field.setCreator('me')
field.setFieldName('signer.sign')
field.setDate()
let d = new npdf.Date(pdfDate(new Date('2012-12-12')))
field.setDate(d)
})
Signing a Document
import {nopodofo as npdf} from 'nopodofo'
const doc = new npdf.Document()
doc.load('/path/to/pdf', e => {
let field =
const signer = new npdf.Signer(doc, '/output/path')
signer.signatureField = field
signer.loadCertificateAndKey('/cert', '/key', (error, signatureLength) => {
if (error) { }
signer.write(signatureLength, (e, d) => {
if (e) { }
})
})
})
Get a Signature
import {nopodofo as npdf} from 'nopodofo'
const doc = new npdf.Document()
doc.load('/path/to/pdf', e => {
let signatures = doc.getSignatures()
if(signatures.length > 0) {
for(let i = 0; i < signature.length; i++) {
const so = signatures[i].getObject()
}
}
})