it is my codes, extraCmds := []string{"-q", "-dBATCH", "-dNOPAUSE", "-dSAFER", "-sDEVICE=pcxmono", fmt.Sprintf("-r%v", dpi), // -r600 "-sOutputFile=BBB%03d.pcx", "WO-BC-CARE.pdf", } s, _ := exec.Command("gs", extraCmds...).Output() reslt := string(s) log.Println(reslt)
show error, 2017/03/21 09:24:48 Error: /undefinedfilename in --findlibfile-- Operand stack: () Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval- - 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- fa lse 1 %stopped_push --nostringval-- 1864 1 3 %oparray_pop --nost ringval-- Dictionary stack: --dict:1200/1684(ro)(G)-- --dict:0/20(G)-- --dict:78/200(L)-- Current allocation mode is local Last OS error: No such file or directory
sounds like can not find ps library, but didn't know how to set gs path with exec.Command. thanks for suggestion in advance.
[update], I solved the issue via upgrading gs from 9.20 to 9.21. Another pitfall need attention while using golang exec.Command. It is do not put quote in parameters, say "BBB%03d.pcx"
. You have to use BBB%03d.pcx
instead.
The error is telling you that a filename was undefined, that it was a library file, and the name of the file was empty. The () are string delimiters and the top of the operand stack contained that string.
You haven't, unfortunately, quoted the entire error message, so I can't tell what version of Ghostscript you are using. I'm going to assume you are using Linux because you have used 'gs'. You also don't say where you got the version of Ghostscript you are using.
You can add directories to the Ghostscript search path by using the -I switch, but that seems unlikely to be helpful here, as you'll presumably still be searching for an empty name, which obviously isn't going to be found.
I would start by printing out the exact command line that you sent to exec, and trying that from the shell, if that works then we can progress further.