受@DietrichvonSeggern建议的启发,我编写了小节点脚本。
const { spawnSync } = require('child_process');
const { stdout } = spawnSync('exiftool',
['-b', '-UserAccess', 'test.pdf'],
{ encoding: 'ascii' });
const bits = (parseInt(stdout, 10) || 0b111111111110);
const perms = {
'Print': 1 << 2,
'Modify': 1 << 3,
'Copy': 1 << 4,
'Annotate': 1 << 5,
'Fill forms': 1 << 8,
'Extract': 1 << 9,
'Assemble': 1 << 10,
'Print high-res': 1 << 11
};
Object.keys(perms).forEach((title) => {
const bit = perms[title];
const yesno = (bits & bit) ? 'YES' : 'NO';
console.log(`${title} => ${yesno}`);
});
Run Code Online (Sandbox Code Playgroud)
它将打印如下内容:
Print => YES
Modify => NO
Copy => NO
Annotate => NO
Fill forms => NO
Extract => NO
Assemble => NO
Print high-res => YES
Run Code Online (Sandbox Code Playgroud)
您应该已经exiftool安装在您的系统中,并向此脚本添加所需的错误检查。
稍作修改:
Print => YES
Modify => NO
Copy => NO
Annotate => NO
Fill forms => NO
Extract => NO
Assemble => NO
Print high-res => YES
Run Code Online (Sandbox Code Playgroud)
将产生:
{
Print: true,
Modify: false,
Copy: false,
Annotate: false,
FillForms: false,
Extract: false,
Assemble: false,
PrintHighRes: true
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
390 次 |
| 最近记录: |