New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

pdf-password

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdf-password

Encrypt, Decrypt and Compress PDF files using Ghostscript

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

pdf-password

Encrypt, Decrypt and Compress PDF files using Ghostscript

npm Package Version

Features

  • Compress PDF without visible quality loss
  • Encrypt PDF with owner and user password
  • Decrypt PDF with password
  • Typescript support

Installation

npm install pdf-password

You can also install pdf-password with pnpm, yarn, or slnpm

Usage Example

import { compressPDF, decryptPDF, encryptPDF } from 'pdf-password'

await compressPDF({
  inFile: 'res/raw.pdf',
  outFile: 'res/compressed.pdf',
})

await encryptPDF({
  inFile: 'res/raw.pdf',
  outFile: 'res/encrypted.pdf',
  ownerPassword: 'DemoOwnerPassword',
  userPassword: 'DemoUserPassword',
})

await decryptPDF({
  inFile: 'res/encrypted.pdf',
  outFile: 'res/decrypted-user.pdf',
  password: 'DemoUserPassword',
})

await decryptPDF({
  inFile: 'res/encrypted.pdf',
  outFile: 'res/decrypted-owner.pdf',
  password: 'DemoOwnerPassword',
})

Typescript Signature

Core Functions:

export function decryptPDF(options: {
  inFile: string
  outFile: string
  password: string
}): Promise<void>

export function encryptPDF(
  options: {
    inFile: string
    outFile: string
  } & (
    | {
        ownerPassword: string
        userPassword: string
      }
    | {
        password: string
      }
  ),
): Promise<void>

export function compressPDF(options: {
  inFile: string
  outFile: string
}): Promise<void>

Error Class:

export class PDFError extends Error {
  code: number | null
  stdout: string
  stderr: string
}

License

This project is licensed with BSD-2-Clause

This is free, libre, and open-source software. It comes down to four essential freedoms [ref]:

  • The freedom to run the program as you wish, for any purpose
  • The freedom to study how the program works, and change it so it does your computing as you wish
  • The freedom to redistribute copies so you can help others
  • The freedom to distribute copies of your modified versions to others

Keywords

decrypt

FAQs

Package last updated on 17 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts