Pdf-lib: [Feature Request]: Document decryption

Created on 7 Nov 2019  路  17Comments  路  Source: Hopding/pdf-lib

I would find it useful to support Encryption Handling as discussed in https://github.com/Hopding/pdf-lib#encryption-handling

feature-request

Most helpful comment

I would also love to see support for encrypted PDFs!

The USCIS website hosts a bunch of encrypted PDFs that could help test this functionality:


Btw @Hopding, thank you for the amazing library. My work revolves around empowering immigrants to successfully navigate the American immigration system, which means dealing with a massive amount of scary forms and documents, so having the tools to manipulate PDFs is essential. You should consider adding a donation link to this repo!

All 17 comments

+1

+1

Please add support, pdfkit has security with this module and crypto-js

By the way, maybe it makes sense to approach this as two separate enhancements: 1) The ability to encrypt and set permissions on a document on save; and 2) The ability to load and decrypt an encrypted document.

@Eric24 I agree. Encryption and decryption should be implemented and released separately. My intent is to track decryption support in this issue, and to track encryption support in https://github.com/Hopding/pdf-lib/issues/243. But I suppose this issue's title doesn't make that especially clear.

Please add.

+1

I would also love to see support for encrypted PDFs!

The USCIS website hosts a bunch of encrypted PDFs that could help test this functionality:


Btw @Hopding, thank you for the amazing library. My work revolves around empowering immigrants to successfully navigate the American immigration system, which means dealing with a massive amount of scary forms and documents, so having the tools to manipulate PDFs is essential. You should consider adding a donation link to this repo!

+1 as well.

+1

+1 - thanks for your work!

+1

Will I be able to resize a pdf if printing is allowed?

Sample file, if this is ever needed
https://www.rotork.com/uploads/documents-versions/41003/1/pub002-039-00_0318.pdf

pub002-039-00_0318.pdf

image

Would be interested in this as well. I tried out the Mozilla pdf.js and it appears to work with all of my sample pdfs.

Facing the same issue, as a workaround you can use node-pdftk, which is a wrapper for PDFtk.

// Example
// Make sure you have PDFtk installed
import * as pdftk from 'node-pdftk';

function removePdfEncryption(input: string | Buffer): Promise<Buffer> {
    return pdftk.input(input).output();
}

@sundowndev Your solution with "pdftk" doesn't work on my end.

Thank you for the idea, but this is what I have come to.
I have built the latest version of "PDFtk" on CentOS and used it because that's a requirement for my project.
Did you get a different result ?

@Hopding, is there any progress on this issue ?

@m-majetic Did you try decrypting the PDF file using PDFtk in the CLI ? May be PDFtk simply cannot decrypt that specific document.

@sundowndev I was able to decrypt that document using "qpdf" in CLI by simply running
qpdf --decrypt encryptedDocument.pdf decryptedDocument.pdf without using any password.

I tried to input an empty password in multiple ways to "PDFtk" in CLI as well, but to no avail.
Maybe there is a special character that should be used as "input_pw" in such a scenario.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matthopson picture matthopson  路  4Comments

fatso83 picture fatso83  路  3Comments

faxemaxee picture faxemaxee  路  6Comments

AlanHadzic picture AlanHadzic  路  3Comments

BoLaMN picture BoLaMN  路  5Comments