to create hand-craft signature with signaturePad, add date and save to a pdf. then add signature PDF as an additional page attach to the main pdf.
** need remove alpha from image in order for pdfKit to create pdf by:
1. set background color to whte
<SignaturePad
ref={sigPad}
backgroundColor="rgba(255,255,255,1)"
canvasProps={{ className: classes.sigPad }}
/>
2. to image/jpeg
const imageData = sigPad.current
.getTrimmedCanvas()
.toDataURL('image/jpeg')
3. merge pdfs using https://www.npmjs.com/package/easy-pdf-merge
export const mergePdfs = async (pdf1: string, pdf2: string, pdf: string) => {
return new Promise((resolve, reject) => {
merge([pdf1, pdf2], pdf, (error: any) => {
if (error) {
return reject(error)
}
resolve('')
})
})
}
====
Here are other ways to sign PDF:
Node Library:
;...const signedPdf = signer;
Comments
Post a Comment