我希望PostScript中的某些文件操作符能够读取或写入外部文件。
我在PostScript程序的同一文件夹(WINDOWS 7)中创建了一个文件input.txt。当Ghostscript解释该行时 (input.txt)(r)文件 错误信息" -illegalfileaccess- in file"被生产。 我的程序行有什么问题?
我在这个论坛上读过有关问题,但答案对我没有帮助。我现在能做什么?
enricoernesto
答案 0 :(得分:2)
按照惯例,后记“文档”不应该访问文件。为了强制执行此约定,GSView和Adobe Acrobat通常会处理禁用file
运算符的文档,因此无法访问文件。使用GSView,您应该能够编辑命令行(在选项中,某处)以删除-DSAFER
字符串。使用ghostscript(以及ps2ps
和ps2pdf
等其他化身),您还可以将-DNOSAFER
添加到命令行,它应该覆盖命令前面的任何-DSAFER
选项字符串。
答案 1 :(得分:1)
尝试运行此代码。它将创建一个新文件output1.txt,然后读取该文件,然后将该文件写回output2.txt。如果每一个都是正确的,你应该有2个文件,否则你没有文件试图的写入权限
/outfile1 (output1.txt) (w) file def
outfile1 (blah blah blah) writestring
outfile1 closefile
/inputfile (output1.txt) (r) file def
inputfile 100 string readstring
pop
inputfile closefile
/outfile2 (output2.txt) (w) file def
outfile2 exch writestring
outfile2 closefile
如果失败,请试试这个。如果这有效,则表明默认位置不可写,但显式路径允许写入,否则为ghostscript,不允许写入。
/outfile1 (c:\\output1.txt) (w) file def
outfile1 (blah blah blah) writestring
outfile1 closefile
/inputfile (c:\\output1.txt) (r) file def
inputfile 100 string readstring
pop
inputfile closefile
/outfile2 (c:\\output2.txt) (w) file def
outfile2 exch writestring
outfile2 closefile
答案 2 :(得分:0)
你还没有发布你的程序,没有它,任何人都无法帮助你。
您是否查看过“Ghostscript如何找到文件”的Ghostscript文档?如果没有,你应该这样做。
您还需要发布正在使用的命令行,例如,如果您使用-dSAFER,则禁止读取某些关键位置之外的文件。