-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add --show-encryption
#31
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Added some comments to this
src/info.ts
Outdated
/** | ||
* Gets the encryption info for a PDF | ||
* @param payload The settings for info | ||
* @returns The output of QPDF | ||
*/ | ||
export const info = async (payload: InfoSettings): Promise<Buffer> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a start we could show whether the file is encrypted or not
/** | |
* Gets the encryption info for a PDF | |
* @param payload The settings for info | |
* @returns The output of QPDF | |
*/ | |
export const info = async (payload: InfoSettings): Promise<Buffer> => { | |
export interface InfoOutput { | |
isEncrypted: boolean; | |
} | |
/** | |
* Gets the encryption info for a PDF | |
* @param payload The settings for info | |
* @returns The output of QPDF | |
*/ | |
export const info = async (payload: InfoSettings): Promise<InfoOutput> => { |
src/info.ts
Outdated
// Input file path | ||
callArguments.push(payload.input); | ||
|
||
return execute(callArguments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here it would be enough to extract the :
params.
I have not tested the following snippet but it might do the trick:
return execute(callArguments); | |
const outputParams = _.keyBy( | |
(await execute(callArguments)) | |
.toString('utf8') | |
.split('\n') | |
.map(line => line.split(':').map(k => k.trim()).splice(0, 2)), | |
p => p[0] | |
); | |
const isEncrypted = outputParams['Has user password'] === 'yes' || outputParams['Has owner password'] === 'yes'; | |
return { isEncrypted }; |
For now, I just left it as the string that qpdf returns. For an unencrypted file, the result will be 'File is not encrypted'.
|
Awesome that works great, thank you |
Fixes #30