
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
A very simple wrapper for qpdf which is a content-preserving transformations on PDF files. It includes encrypting and decrypting PDF with AES 256, AES 128, RC4 (128 & 40) encryption algorithms.
npm install node-qpdf
You can encrypt your PDF by following:
var qpdf = require('node-qpdf');
var options = {
keyLength: 128,
password: 'YOUR_PASSWORD_TO_ENCRYPT'
}
qpdf.encrypt(localFilePath, options);
The following are required options
keyLength: - a number which defines the encryption algorithm to be used. Values can be 40, 128 and 256 only.password: - a string containing the secret password which will be further used to unlock the PDF.You might want to set other options for each encryption algorithm inside restrictions: JSON according to the keyLength you choose :-
Key Length: 40
| Option | Value | Description |
|---|---|---|
print: | 'y', 'n' | Determines whether or not to allow printing. |
modify: | 'y', 'n' | Determines whether or not to allow document modification. |
extract: | 'y', 'n' | Determines whether or not to allow text/image extraction. |
annotate: | 'y', 'n' | Determines whether or not to allow comments and form fill-in and signing. |
Key Length: 128
| Option | Value | Description |
|---|---|---|
print: | 'full', 'low', 'none' | full: allow full printing. low: allow low-resolution printing only. none: disallow printing. |
modify: | 'all', 'annotate', 'form', 'assembly', 'none' | all: allow full document modification. annotate: allow comment authoring and form operations. form: allow form field fill-in and signing. assembly: allow document assembly only. none: allow no modifications. |
extract: | 'y', 'n' | Determines whether or not to allow text/image extraction. |
useAes: | 'y', 'n' | AES encryption will be used instead of RC4 encryption. |
accessibility: | 'y', 'n' | Determines whether or not to allow accessibility to visually impaired. |
Key Length: 256
| Option | Value | Description |
|---|---|---|
print: | 'full', 'low', 'none' | full: allow full printing. low: allow low-resolution printing only. none: disallow printing. |
modify: | 'all', 'annotate', 'form', 'assembly', 'none' | all: allow full document modification. annotate: allow comment authoring and form operations. form: allow form field fill-in and signing. assembly: allow document assembly only. none: allow no modifications. |
extract: | 'y', 'n' | Determines whether or not to allow text/image extraction. |
accessibility: | 'y', 'n' | Determines whether or not to allow accessibility to visually impaired. |
var qpdf = require('node-qpdf');
var options = {
keyLength: 128,
password: 'YOUR_PASSWORD_TO_ENCRYPT',
restrictions: {
print: 'low',
useAes: 'y'
}
}
qpdf.encrypt(localFilePath, options, outputFilePath);
var qpdf = require('node-qpdf');
var options = {
keyLength: 256,
password: 'YOUR_PASSWORD_TO_ENCRYPT',
restrictions: {
modify: 'none',
extract: 'n'
}
}
var doc = qpdf.encrypt(localFilePath, options, outputFilePath);
doc.stdout.pipe(res);
res.writeHead(200, {
'Content-Type': 'application/pdf',
'Access-Control-Allow-Origin': '*',
'Content-Disposition': 'inline; filename=order.pdf'
});
You can decrypt your PDF by following:
var qpdf = require('node-qpdf');
qpdf.decrypt(localFilePath, 'YOUR_PASSWORD_TO_DECRYPT_PDF');
var qpdf = require('node-qpdf');
qpdf.decrypt(localFilePath, 'YOUR_PASSWORD_TO_DECRYPT_PDF', outputFilePath);
var qpdf = require('node-qpdf');
var doc = qpdf.decrypt(localFilePath, 'YOUR_PASSWORD_TO_DECRYPT_PDF', outputFilePath);
doc.stdout.pipe(res);
res.writeHead(200, {
'Content-Type': 'application/pdf',
'Access-Control-Allow-Origin': '*',
'Content-Disposition': 'inline; filename=order.pdf'
});
Maintained by Nishit Hirani
Bug reports and pull requests are welcome on GitHub at https://github.com/nrhirani/node-qpdf.
The npm package is available as open source under the terms of the MIT License.
FAQs
A Content Preserving transformations on PDFs wrapped around QPDF
The npm package node-qpdf receives a total of 22,401 weekly downloads. As such, node-qpdf popularity was classified as popular.
We found that node-qpdf demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.