galkahana / HummusJS

Node.js module for high performance creation, modification and parsing of PDF files and streams
http://www.pdfhummus.com
Other
1.14k stars 169 forks source link

How to recrypt file without saving it? #299

Open nkaredia opened 6 years ago

nkaredia commented 6 years ago

Sorry I couldn't find any documentation for this.

I'm trying to open a password protected pdf file and read the text of it before saving it conditionally.

This is what I'm using right now.

hummus.recrypt('/path/of/origin', 'path/of/output', { password: '123456' });

Is it possible to just output the contents to a readable stream instead of saving a new file?

galkahana commented 6 years ago

you can replace the two paths with two custom streams. you can read about it here: https://github.com/galkahana/HummusJS/wiki/Streams

there's 4 custom stream types built into hummus: https://github.com/galkahana/HummusJS/blob/master/hummus.js#L27

you can create one that fits the scenario you're looking at. one thing to make sure that you do - if you're using stream for one params, also use for the other. cant mix paths and streams.

Gal.