mooz / node-pdf-image

Provides an interface to convert PDF's pages to png files in Node.js by using ImageMagick
MIT License
237 stars 87 forks source link

Failed to convert page to image #42

Open siamraj opened 6 years ago

siamraj commented 6 years ago

issues

My Code : var fs = require('fs'); var PDFImage = require("pdf-image").PDFImage;

var pdfImage = new PDFImage("test.pdf"); pdfImage.convertPage(0).then(function (imagePath) { // 0-th page (first page) of the slide.pdf is available as slide-0.png fs.existsSync("Public/slide-0.png") // => true }).catch((err)=>{ console.log(err) });

Error MSG :

{ message: 'Failed to convert page to image', error: { Error: Command failed: convert "test.pdf[0]" "test-0.png" Invalid Parameter - "test-0.png"

at ChildProcess.exithandler (child_process.js:275:12)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Socket.stream.socket.on (internal/child_process.js:346:11)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at Pipe._handle.close [as _onclose] (net.js:554:12)
 killed: false,
 code: 4,
 signal: null,
 cmd: 'convert "test.pdf[0]" "test-0.png"' },

stdout: '', stderr: 'Invalid Parameter - "test-0.png"\r\n' }

roest01 commented 6 years ago

Hey @siamraj, You have this problem because the convert process didn't worked. The error message might can be optimised here but primarily you have to fix the convert command. Try this on your command line - this will fail: convert "test.pdf[1]" "test-0.png"

You already found: #30

Try to install pdf-poppler or poppler with brew as described in readme