如何用C语言创建PS(PostScript)文件?
例如,我想创建文件myfile.ps并绘制到PostScript这段代码:
%!
newpath
0 0 moveto
120 120 lineto
144 120 lineto
200 122 lineto
0 0 lineto
stroke
showpage
答案 0 :(得分:3)
通常后记只是ascii文本,所以标准的文本输出设施就可以了。
#include <stdio.h>
int main(void) {
FILE *outfile;
outfile = fopen("myfile.ps", "w");
fprintf(outfile,
"%%!\n"
"%d %d moveto\n"
"%d %d lineto\n"
"%d %d lineto\n"
"%d %d lineto\n"
"%d %d lineto\n"
"stroke\n"
"showpage\n",
0, 0,
120, 120,
144, 120,
200, 122,
0, 0
);
return 0;
}