我有一些引用字体的PDF文件,希望使用Ghost4J将其输出为包含嵌入字体的PDF文件。
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文件时,我会遇到以下错误:
ERROR: Cannot initialize Ghostscript interpreter. Error code is -100
在命令行中运行时,参数能够正常工作。
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
跟进:
- GhostScript拥有写入C:的权限。
- 我已经删除了所有开关,除了outputPath,“-f”,inputPath,并且仍然出现错误。
- 在inputPath后面的cmdStr末尾去掉逗号。
注释:
- 我正在努力获取回调函数。