2014-09-06 137 views
1

我希望PostScript中的某些文件操作符可以读取或写入外部文件。postscript中的文件输入/输出

我在与PostScript程序相同的文件夹(WINDOWS 7)中创建了一个文件input.txt。当Ghostscript解释行 (input.txt)(r)文件 时,会生成错误消息“-illegalfileaccess- in file”。 我的程序行有什么问题?

我在这个论坛上看到有关问题,但答案并没有帮助我。我现在能做什么?

enricoernesto

回答

0

您还没有发布你的程序,有没有办法,任何人都可以帮助你不说。

你看了看'Ghostscript如何找到文件'的Ghostscript文档?如果不是,你应该这样做。

您还需要发布您正在使用的命令行,例如,如果您正在使用-dSAFER,则禁止在某些关键位置之外读取文件。

1

试着运行这段代码。它将创建一个新文件output1.txt,然后读取该文件,然后将该文件写回到output2.txt。如果everyting是正确的,你应该有2个文件,否则你不必在文件试图为w

/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

按照惯例,后记“文档”不应该访问文件。为了执行这个约定,GSView和Adobe Acrobat通常处理文档,file操作符被禁用,因此它不能访问文件。使用GSView,您应该能够编辑命令行(在选项中的某处)以删除-DSAFER字符串。使用ghostscript(以及其他形式,例如ps2psps2pdf),您还可以将-DNOSAFER添加到命令行中,并且它应该在命令字符串的前面覆盖任何-DSAFER选项。

+0

我通过GSView/Options将-dNOSAFER - 字符串放入Ghostscript的开始命令中,现在我的ps-Program能正常工作! – enricoernesto 2014-09-07 15:16:26