encrypt-decrpt-pdf
TypeScript icon, indicating that this package has built-in type declarations

1.0.11 • Public • Published

Build Status

Encrypting and Decrypting PDF files with Nodejs

A nodejs library implemented in TS to convieniently encrypt and decrypt pdf documents and save to disk.

Compactibility

VanillaJS, ES5, ES6 and Typescript

Dependecies

Majorly depends on Linux qpdf

Installation

Install qpdf

sudo apt-get install -y qpdf

Install encrypt-decrpt-pdf

npm i encrypt-decrpt-pdf

Using Encrypt-Decrypt-PDF

Intializing in JS

const path = require('path');
const Processor = require('encrypt-decrpt-pdf').PDFProcessor;

const password = 'testpassword';
const username = "testusername";

const processor = new Processor(password, username);

Declaring Parameters


const sourcepath = path.join(__dirname, 'path to file');
const destpath = path.join(__dirname, 'path to file');

const encryptmethod = 'encrypt'
const decryptmethod = 'decrypt'

After initializing, you can use the process method to encrypt/decrypt any PDF file with the correct parameters needed.

Encrypting PDF

processor
  .encrypt(destpath, sourcepath)
  .then(data => console.log(data))
  .catch(err => console.log(err));

DEcrypting PDF

processor
  .decrypt(sourcepath, destpath)
  .then(data => console.log(data))
  .catch(err => console.log(err));

Contributions are very welcome!

Dependencies (0)

    Dev Dependencies (12)

    Package Sidebar

    Install

    npm i encrypt-decrpt-pdf

    Weekly Downloads

    64

    Version

    1.0.11

    License

    ISC

    Unpacked Size

    55.1 kB

    Total Files

    30

    Last publish

    Collaborators

    • alayesanmi