2017-02-14 49 views
1
var fs  = require('fs'); 
var pdf2img = require('pdf2img'); 

var input = __dirname+'\\public\\pdfs\\User.pdf'; 

pdf2img.setOptions({ 
    type: 'png',      // png or jpeg, default png 
    size: 1024,      // default 1024 
    density: 600,      // default 600 
    outputdir: __dirname+'\\public\\pdfs', // mandatory, outputdir must be absolute path 
    targetname: 'test'    // the prefix for the generated files, optional 
}); 

pdf2img.convert(input, function(err, info) { 
    if (err) console.log(err) 
    else console.log(info); 
}); 

运行此我得到以下错误后:pdf2img在节点JS给人一种错误“标识”不被识别为一个内部或外部命令

'identify' is not recognized as an internal or external command, 
operable program or batch file. 
child_process.js:508 
throw err; 
^ 

Error: Command failed: identify -format %n C:\Users\pr326323\Pictures\samp\public\pdfs\User.pdf 
'identify' is not recognized as an internal or external command, operable program or batch file. 

at checkExecSyncError (child_process.js:465:13) 
at execSync (child_process.js:505:13) 
at async.waterfall.pages (C:\Users\pr326323\Pictures\samp\node_modules\pdf2img\lib\pdf2img.js:47:32) 
at fn (C:\Users\pr326323\Pictures\samp\node_modules\pdf2img\node_modules\async\lib\async.js:638:34) 
at Immediate._onImmediate (C:\Users\pr326323\Pictures\samp\node_modules\pdf2img\node_modules\async\lib\async.js:554:34) 
at processImmediate [as _immediateCallback] (timers.js:383:17) 

回答

0

假设你有Ubuntu系统。您还必须为此库安装Dependency。运行以下命令:

sudo apt-get install graphicsmagick 
相关问题