Simple Example Sign PDF
See original GitHub issueI don’t know, why You not create simple example for this library? Not all users know how use this library…
- How to import Your library? especially plainAddPlaceholder
- How create p12 certificate?
- How write signed pdf to file?
- How change “Signed by signedpdf signpdf@example.com” in pdf file?
I read this README, but You only reference code tester
I have look at issue but You not clear answer, for example (https://github.com/vbuch/node-signpdf/issues/126), but You not answer with clear answer 😦 You may need to add add 'dist' to the import path. something like 'node-sginpdf/dist/helpers/plainAddPlaceholder'
why You dont answer with const { plainAddPlaceholder } = require('node-signpdf/dist/helpers');
I have googling but I don’t get anything that help me
For other, if You confuse, You can read this simple example
const signer = require('node-signpdf').default
const fs = require('fs')
const { plainAddPlaceholder } = require('node-signpdf/dist/helpers');
const pdfSignedPath = `./signed.pdf`;
const pdfBuffer = fs.readFileSync(`./source.pdf`);
const certBuffer = fs.readFileSync(`./certificate.p12`);
let inputBuffer = plainAddPlaceholder({
pdfBuffer,
reason: 'Signed Certificate.',
contactInfo: 'sign@example.com',
name: 'Example',
location: 'Jakarta',
signatureLength: certBuffer.length,
});
const signedPdf = signer.sign(
inputBuffer,
certBuffer,
{ asn1StrictParsing : true },
);
fs.writeFileSync(pdfSignedPath, signedPdf);
source.pdf is file pdf that will signed signed.pdf is target of signed file certificate.p12 is Your certificate, generate this with openssl or You can use sample in folder ‘resources’ of this library
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:10 (1 by maintainers)
Top Related StackOverflow Question
¡Hello! I’m getting the following error while trying to run @hscstudio and @fdimarh example:
¿What am I missing?
I tried to run it locally, and I got the same error message. Here is the Replit Link where you can reproduce the issue. Thank you for the help!
Maybe this snippet code will help you get better understanding to signing PDF with this library