java – Ghost4J / Ghostscript – 尝试将字体嵌入PDF时获得错误
发布时间:2020-12-15 02:33:35 所属栏目:Java 来源:网络整理
导读:我有带引用字体的PDF,我想使用Ghost4J输出包含嵌入字体的PDF. public void execute() { Ghostscript gs = Ghostscript.getInstance(); String[] cmdStr={ "-dNOPAUSE","-dBATCH","-dCompatibilityLevel=1.4","-dPDFSETTINGS=/prepress","-dSAFER","-dNOPLATF
我有带引用字体的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:WINNTFonts;C:Program Filesgsgs9.05lib;C:Program Filesgsgs9.05bin;","-dSubsetFonts=true","-dEmbedAllFonts=true","-sFONTPATH=C:WINNTFonts","-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:WINNTFonts -sOutputFile=c:out.pdf -f c:test.pdf 随访: > GhostScript有权写入C:. 笔记: >我正在努力获得回调 解决方法
你的inputPath变量后面有一个逗号.这是无效的Java语法.
我在生产java应用程序中使用ghostscript从PDF生成PCL文件.我使用java.lang.Runtime类来执行Ghostscript可执行文件,因此我无法直接为Ghost4J提供建议. 我怀疑问题是api不知道支持文件的位置.尝试传递字体,lib和bin位置的完整路径,如下所示. "-Ic:Program Files (x86)gsfonts;c:Program Files (x86)gslib;c:Program Files (x86)gsbin;" (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |