getting ghostscript to take in files with spaces in their name (like something in “my documents”)

半世苍凉 提交于 2019-12-24 07:35:37

问题


I'm trying to run this command to use ghostscript (from java) but Whether with single quote ' or " or nothing at all I get an error

Error: /undefinedfilename in ('c:\\Documents)


gswin32c.exe -q -dNOPAUSE -sDEVICE=tiffgray -sOutputFile=C:\polter.tiff -r300 'c:\Documents and Settings\polter.pdf' -c quit

any ideas?


回答1:


use the short names for folders. short names are aliases which are using the 8.3 format. you can find the short name of a folder by using the dir /x command on the command prompt. your path will then look something like this: c:\docume~1\polter.pdf




回答2:


Break up the arguments yourself:

String[] cmd = {
  "gswin32c.exe",
  "-q", "-dNOPAUSE", "-sDEVICE=tiffgray",
  "-sOutputFile=C:\polter.tiff", "-r300",
  "c:\Documents and Settings\polter.pdf",
  "-c", "quit"
};
Runtime.getRuntime().exec(cmd);


来源:https://stackoverflow.com/questions/1804646/getting-ghostscript-to-take-in-files-with-spaces-in-their-name-like-something-i

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!