我正在使用https://www.npmjs.com/package/pdf-image。
但我遇到了这个错误。
var PDFImage = require("pdf-image").PDFImage;
var pdfImage = new PDFImage("brochure.pdf");
pdfImage.convertPage(0).then(function (imagePath) {
// 0-th page (first page) of the slide.pdf is available as slide-0.png
fs.existsSync("slide-0.png") // => true
},function(err){
console.log(err);
});
但我遇到了这个错误。
{ message: 'Failed to convert page to image',
error:
{ [Error: Command failed: /bin/sh -c convert 'brochure.pdf[0]' 'brochure-0.png'
/bin/sh: 1: convert: not found
]
killed: false,
code: 127,
signal: null,
cmd: '/bin/sh -c convert \'brochure.pdf[0]\' \'brochure-0.png\'' },
stdout: '',
stderr: '/bin/sh: 1: convert: not found\n' }
请帮我,如何使用Node.js将PDF转换为图像。
which convert
,会得到什么结果? - Karamellexport MAGICK_HOME="opt/ImageMagick" && export PATH="$MAGICK_HOME/bin:$PATH" && export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib"
- Karamell