Node.JS PDFKit Library Example to Encrypt PDF Documents With Password in Javascript on Command Line

You are currently viewing Node.JS PDFKit Library Example to Encrypt PDF Documents With Password in Javascript on Command Line

Node.js PDFKit Library Example to Encrypt PDF Documents With Password in Javascript on Command Line

const PDFDocument = require("pdfkit");
const fs = require("fs");
 
var options = {
    userPassword: "123456",
}
 
// Create a document
const doc = new PDFDocument(options);
 
// Pipe its output somewhere, like to a file or HTTP response
// See below for browser usage
doc.pipe(fs.createWriteStream("output.pdf"));
 
doc.addPage()
// Finalize PDF file
doc.end();

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply