2012-04-23 3 views
4

참조 된 글꼴이있는 PDF가 있으며 포함 된 글꼴이 포함 된 PDF를 출력하려면 Ghost4J를 사용하고 싶습니다.Ghost4J/Ghostscript - 글꼴을 PDF에 포함하려고 할 때 오류 100 발생

ERROR: Cannot initialize Ghostscript interpreter. Error code is -100 

인수가 제대로 작동 명령 줄에서 실행 :

public void execute() { 
    Ghostscript gs = Ghostscript.getInstance(); 
    String[] cmdStr={ 
     "-dNOPAUSE","-dBATCH","-dCompatibilityLevel=1.4", 
     "-dPDFSETTINGS=/prepress","-dSAFER","-dNOPLATFONTS", 
     "-sDEVICE=display","-sPAPERSIZE=letter", 
     "-I","C:\\WINNT\\Fonts\\;C:\\Program Files\\gs\\gs9.05\\lib\\;C:\\Program Files\\gs\\gs9.05\\bin\\;", 
     "-dSubsetFonts=true","-dEmbedAllFonts=true", 
     "-sFONTPATH=C:\\WINNT\\Fonts", "-sOutputFile=", 
     outputPath,"-c",".setpdfwrite", "-f",inputPath 
    };  
    try { 

     gs.initialize(cmdStr); 
     gs.exit(); 

    } catch (GhostscriptException e) {   
     System.out.println("ERROR: " + e.getMessage()); 
     e.printStackTrace(); 
    } 

나는 다음과 같은 오류가있는 PDF를 실행

.

gswin32c.exe -dNOPAUSE -dBATCH -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dSafer -NOPLATFONTS -sDEVICE=pdfwrite -sPAPERSIZE=letter -dSubsetFonts=true -dEmbedAllFonts=true -sFONTPATH=C:\\WINNT\\Fonts -sOutputFile=c:\out.pdf -f c:\test.pdf 

후속 :

  • 고스트 스크립트는 C에 쓸 수있는 권한이 :.
  • 내가 outputPath를 제외하고 모든 스위치를 제거했다 "-f"inputPath 나는 여전히 inputPath
  • 후 CMDSTR의 끝에서 오류를

노트를

  • 제거 쉼표를 얻을 :

    • 콜백을 받고 있습니다.
  • +0

    내가 Ghost4J에 대해 아무것도 모르겠지만 .... 이러한 매개 변수'-ps2pdf'합니다. 또한, 코드 예제의 cmdStr에서 Windows에서 작동하는'gswin32c.exe' (유닉스에서 작동하는'gs' 만)를 찾지 못했습니다 ... –

    +0

    Ghost4J는 C++ 용 Ghostscript 암호. http://ghost4j.sourceforge.net/ – eabraham

    +0

    너무 많이 추측했습니다 ...하지만 Java 코드에서 Ghostscript를 호출하는 방법이 맞습니까? –

    답변

    1

    inputPath 변수 뒤에 쉼표가 있습니다. 잘못된 Java 구문입니다.

    프로덕션 자바 응용 프로그램에서 ghostscript를 사용하여 PDF에서 PCL 파일을 생성합니다. java.lang.Runtime 클래스를 사용하여 Ghostscript 실행 파일을 실행하므로 Ghost4J에 대한 직접적인 조언을 드릴 수 없습니다.

    api가 지원 파일의 위치를 ​​알지 못하는 것으로 의심됩니다. 다음과 같이 글꼴, lib 및 bin 위치의 전체 경로를 전달하십시오. 고스트 명령 줄 나에게 익숙하지 -psconv``

    "-Ic:\Program Files (x86)\gs\fonts\;c:\Program Files (x86)\gs\lib\;c:\Program Files (x86)\gs\bin\;" 
    
    +0

    쉼표가 맞지만 여전히 오류 메시지가 표시됩니다. – eabraham