简体   繁体   English

"PDF2pic:错误:在转换 pdf 时写入 EPIPE 错误"

[英]PDF2pic: Error: write EPIPE error on converting pdf

I am trying to convert a pdf document in to images (each page as separate image).我正在尝试将 pdf 文档转换为图像(每页作为单独的图像)。 I am using the package pdf2pic.我正在使用包 pdf2pic。 I tried to convert a pdfenter code here and getting the error.我试图在这里转换一个 pdfenter 代码并得到错误。 can any one help me what i made wrong here谁能帮我我在这里做错了什么

The error I am getting我得到的错误

Error: write EPIPE
    at afterWriteDispatched (internal/stream_base_commons.js:156:25)
    at writeGeneric (internal/stream_base_commons.js:147:3)
    at Socket._writeGeneric (net.js:785:11)
    at Socket._write (net.js:797:8)
    at writeOrBuffer (internal/streams/writable.js:358:12)
    at Socket.Writable.write (internal/streams/writable.js:303:10)
    at ReadStream.ondata (internal/streams/readable.js:745:22)
    at ReadStream.emit (events.js:376:20)
    at ReadStream.Readable.read (internal/streams/readable.js:519:10)
    at flow (internal/streams/readable.js:1001:34) {
  errno: -4047,
  code: 'EPIPE',
  syscall: 'write'
}


const { fromBase64, fromPath } = require("pdf2pic");
const { mkdirsSync, readFileSync } = require("fs-extra");
const rimraf = require("rimraf");

module.exports = () => {
  const specimen1 = "./files/specimen1.pdf";
  const outputDirectory = "./output";
  
  rimraf.sync(outputDirectory);
  mkdirsSync(outputDirectory);
  
  const options = {
    density: 100,
    saveFilename: "untitled",
    savePath: outputDirectory,
    format: "png",
    width: 600,
    height: 600
  };
  
  const storeAsImage = fromPath(specimen1, options);
  return storeAsImage(1).then( res=> { console.log(res)}).catch(error =>{ console.log(error)})
}

Thanks谢谢

same problem here, have you fixed this issue?同样的问题,你解决了这个问题吗? if so, what is the fix?如果是这样,修复方法是什么? thx.谢谢。

I had this issue while using Windows.我在使用 Windows 时遇到了这个问题。 You will need ImageMagick, which isn't automatically installed on later versions on GraphicsMagick.您将需要 ImageMagick,它不会自动安装在 GraphicsMagick 的更高版本中。 The solution was to download GraphicsMagick from the source code.解决方案是从源代码下载 GraphicsMagick。 See: https://github.com/yakovmeister/pdf2image/blob/HEAD/docs/gm-installation.md http://www.graphicsmagick.org/INSTALL-windows.html请参阅: https ://github.com/yakovmeister/pdf2image/blob/HEAD/docs/gm-installation.md http://www.graphicsmagick.org/INSTALL-windows.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM