Skip to content

This function takes a PDF file in Base64 format (inputBase64) and a password (password) as input. It encrypts the PDF file with the specified password and returns the encrypted PDF content in Base64 format through a callback function.

License

RigobertoCarrilloLopez/mxtools-pdf-encrypt

Repository files navigation

mxtools-pdf-encrypt

A Node.js package for encrypting PDF files with password protection, supporting both Windows and Linux.

Installation

Install the package using npm: npm install mxtools-pdf-encrypt

Usage

Encrypt a PDF from a Base64 string

const { encryptPdfBase64 } = require('mxtools-pdf-encrypt');

const inputBase64 = 'yourBase64StringHere';
const password = 'yourPasswordHere';

encryptPdfBase64(inputBase64, password, (err, encryptedBase64) => {
    if (err) {
        console.error(`Error: ${err.message}`);
    } else {
        console.log('Encrypted PDF in Base64:', encryptedBase64);
    }
});
const { encryptPdfFile } = require('mxtools-pdf-encrypt');

const inputFilePath = 'path/to/input.pdf';
const outputFilePath = 'path/to/output.pdf';
const password = 'yourPasswordHere';

encryptPdfFile(inputFilePath, outputFilePath, password, (err, outputFilePath) => {
    if (err) {
        console.error(`Error: ${err.message}`);
    } else {
        console.log(`Encrypted PDF saved to: ${outputFilePath}`);
    }
});


License
This package is licensed under the MIT License.


You can customize this README.md as needed for your package. Feel free to add more details, usage examples, or any other information you find relevant.

About

This function takes a PDF file in Base64 format (inputBase64) and a password (password) as input. It encrypts the PDF file with the specified password and returns the encrypted PDF content in Base64 format through a callback function.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published