How to Encrypt PDF Files with Password in Node.js Using Hummus Recipe Library

How to Encrypt PDF Files with Password in Node.js Using Hummus Recipe Library

Welcome folks today in this post we will be talking about how to encrypt pdf files with password in node.js using a library called Hummus Recipe Library. All the source code of the application is given below. A step by step youtube video is also shown below.

 

 

Get Started

 

Official Link of Library

 

In order to get started we need to first of all create a brand new node.js project and execute the following command to install this package

See also  Javascript Project to Export SVG DOM Element to SVG,PNG Image and PDF Document in Browser Full Project For Beginners

 


npm i hummus-recipe --save

 

Now make the index.js file which will be the starting point of the application and copy paste the following code

 

 

const HummusRecipe = require('hummus-recipe');
const pdfDoc = new HummusRecipe('##inputfile##.pdf', '##outputfile##.pdf');
 
pdfDoc
    .encrypt({
        userPassword: '123',
        ownerPassword: '123',
        userProtectionFlag: 4
    })
    .endPDF();

 

 

Methods Used

 

  1. Encrypt: This method is used to encrypt the pdf files with a password. Here we have used the password 123.
See also  How to Automate Omegle in Javascript | Build a Simple Omegle Bot in Javascript Full Project

 

Output PDF

 

 

Leave a Reply