npmkyc
v1.0.0
Published
Generate KYC PDFs and extract PDF pages from Node.js.
Readme
npmKYC
npmKYC is a Node.js package for:
- generating KYC PDFs from the bundled EJS template
- converting remote PDF documents into inline images for the template
- extracting selected pages from an existing PDF
Install
npm install npmkycUse as a package
const { createKycPdf, extractPdfPages } = require("npmkyc");
async function main() {
const pdf = await createKycPdf({
id: "12345",
applicant_name: "Aman Sharma",
aadhar: "https://example.com/aadhar.pdf",
pancard: "https://example.com/pan.pdf",
statement: "https://example.com/statement.pdf",
});
const extracted = await extractPdfPages({
pdfUrl: "https://example.com/source.pdf",
pages: [1, 3],
});
console.log(pdf.length, extracted.length);
}
main().catch(console.error);Use as an API server
PORT=3000 CHROME_PATH=/path/to/chrome npm startAvailable routes:
POST /api/generate-kycPOST /api/kra
Exported API
createKycPdf(data, options?)extractPdfPages({ pdfUrl, pages })createKycApp(options?)getPdfAsImages(pdfUrl, options?)renderKycHtml(data, options?)
Notes
- The package expects a working Chromium or Chrome executable for Puppeteer.
- By default it looks at
process.env.CHROME_PATH, then/snap/chromium/current/usr/lib/chromium-browser/chrome.
