2016-06-29 2 views
0

나는 https://www.npmjs.com/package/pdf-image을 사용하고 있습니다.nodejs pdf - 이미지 변환

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); 
      }); 

는하지만 난 nodejs를 사용하여 이미지를 PDF로 변환 할 수있는 방법 제발 도와주세요이 오류

{ 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' } 

을 얻고있다.

답변

0

패키지를 작동 시키려면 ImageMagick을 다운로드해야합니다. 설명서에서 설치 지침을 확인하십시오. here

이미 수행 한 경우 경로 구성에 문제가있을 수 있습니다. 이 문제를 해결하려면 다음 명령을 시도해보십시오

export MAGICK_HOME="opt/ImageMagick" export DYLD_LIBRARY_PATH="$MAGICK_HOME/lib export PATH="$MAGICK_HOME/bin:$PATH"

+0

난 이미 성공적으로이 명령을 실행했다. sudo apt-get install imagemagick 고스트 스크립트 poppler-utils @Karamell –

+0

'which convert'를 실행하면 어떤 결과가 나옵니까? – Karamell

+0

경로를 설정해야하는 경우, 터미널에 입력하여 (asuming mac 또는 unix) : export MAGICK_HOME = "opt/ImageMagick"&& export PATH = "$ MAGICK_HOME/bin : $ PATH"&& export DYLD_LIBRARY_PATH = "$ MAGICK_HOME/lib"' – Karamell