From 81c4b128afbb9e089e1eaa0ea4f5892806885c66 Mon Sep 17 00:00:00 2001 From: Valery Buchinsky Date: Fri, 28 Jun 2019 16:25:12 +0300 Subject: [PATCH] :pencil: --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f42a6261..b6fe4249 100644 --- a/README.md +++ b/README.md @@ -31,17 +31,26 @@ In practice we expect that most people will just read through the code we've wri ### With pdfkit-created document -You have already created a PDF using foliojs/pdfkit and you want to sign that. Here's how this becomes possible: +You have already created a PDF using foliojs/pdfkit and you want to sign that. Before saving (writing to fs) your file, you need to a add a signature placehoolder to it. We have a helper for that. This is dempnstrated in [the `signs input PDF` test](./src/signpdf.test.js#L111). -Before saving your file, you need to a add a signature placehoolder to it. We have a helper for that. - -Once you have the placeholder, just [sign the document]. +Once you have the placeholder, just [[sign the document]](#sign-the-document). ### With any PDF document -Yes. This is new since version 1.0. We have a helper that can add a signature placeholder in at least the most basic PDFs without depending on pdfkit. +Yes. This is new since version 1.0. We have a helper that can add a signature placeholder in at least the most basic PDFs without depending on pdfkit. You can see how this is done in [the `signs a ready pdf` test](./src/signpdf.test.js#L136). + +Once you have the placeholder, just [[sign the document]](#sign-the-document). + +### Sign the document -Once you have the placeholder, just [sign the document]. +```javascript +import signer from 'node-signpdf'; +... +const signedPdf = signer.sign( + fs.readFileSync(PATH_TO_PDF_FILE) + fs.readFileSync(PATH_TO_P12_CERTIFICATE), +); +``` ## Notes