var PDFImage = require(“pdf-image”).PDFImage;
var fs = require(“fs”);
var pdfImage = new PDFImage(“tmp/testpdf.pdf”);
console.log(“Start”);
pdfImage.convertPage(0).then(function (imagePath) {
// 0-th page (first page) of the slide.pdf is available as slide-0.png
console.log(“Converted.”);
fs.existsSync(“tmp/testpdf-0.png”) // => true
});
https://www.npmjs.com/package/pdf-image ?
@elrrrrrrr 谢谢了
@elrrrrrrr @martin823823 我安装了imageMagic,但是运行的时候没报错也没图片生成,请问你们遇到过吗?
testpdf在个F:\parseWord\tmp里
@SHocker-Yu var pdfImage = new PDFImage(“tmp/testpdf.pdf”); 传入的是文件的路径-》F:\parseWord\tmp\testpdf.pdf
@SHocker-Yu 你把imagePath打印出来看看
@martin823823 感谢回复,路径确认很多遍,绝对路径也正如你打出来的一样试过了,imagePath打不出来,程序没有运行到里面就结束了。 最后是换了gm这个包,感觉很强大,https://github.com/aheckmann/gm
@SHocker-Yu 按照你的办法,我这边提示。
@zhailei31665431 周末没上社区,不好意思,这是因为没有安装ghostscript,下载地址:http://ghostscript.com/download/gsdnld.html