我正在尝试使用节点-qpdf
我只是做了个简单的:
Test.pdf位于index.js所在的目录中。
var qpdf = require('node-qpdf');
var options = {
keyLength: 128,
password: 'test123',
restrictions: {
print: 'low',
useAes: 'y'
}
}
var localFilePath ='Test.pdf';
var outputFilePath ='test';
qpdf.encrypt(localFilePath, options, outputFilePath);我犯了错误,就像:
Run: nodemon index.js
[nodemon] 2.0.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching dir(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node index.js`
C:\Users\Rad\Desktop\node-qpdf-master\test\node_modules\node-qpdf\index.js:56
return callback(null, outputStream);
^
TypeError: callback is not a function
at Object.Qpdf.encrypt (C:\Users\Rad\Desktop\node-qpdf-master\test\node_modules\node-qpdf\index.js:56:16)
at Object.<anonymous> (C:\Users\Rad\Desktop\node-qpdf-master\test\index.js:13:6)
at Module._compile (internal/modules/cjs/loader.js:945:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:962:10)
at Module.load (internal/modules/cjs/loader.js:798:32)
at Function.Module._load (internal/modules/cjs/loader.js:711:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:1014:10)
at internal/main/run_main_module.js:17:11
[nodemon] app crashed - waiting for file changes before starting...发布于 2020-08-04 10:14:58
我想他们还没有更新文档,我读了他们的代码,你必须把outputFile和options修改成这样。
var options = {
keyLength: 256,
password: '12345',
outputFile: '<your output name file>',
restrictions: {
modify: 'none',
extract: 'n'
}
var doc = await qpdf.encrypt(`${fileLocation}.pdf`, options)https://stackoverflow.com/questions/60562788
复制相似问题