Search code examples
c#postscript

Adding Form in PostScript


i have a c# application in which i want to insert a message in postscript file, so i created a form like

%%BeginResource: form myfrm
/myfrm 
<<
/FormType 1
/BBox [ 0 0 771 618] def
/Matrix [1 0 0 1 0 0] def
/PaintProc{pop
..........
}
>> /Form defineresource pop
%%EndResource

when i insert in page in page like this

newpath
gsave
3800 5025 translate
3221.875 2575 scale
myfrm execform
grestore
closepath

it gives me error when i view in ghostview. Any suggestion what i am doing wrong , previously what i was doing was create an image from text and insert in as EPS form it is working great but ps file size was increased.and also if possible can i insert a textbox in postscript.

after edit :-

/myfrm 
<<
/FormType 1
/BBox [ 0 0 771 618] 
/Matrix [1 0 0 1 0 0] 
/PaintProc{pop
0 0 moveto
(my name is ali) show
}
>> def

.....
.....
.....
newpath
gsave
3800 5025 translate
3221.875 2575 scale
myfrm execform
grestore
closepath 

but no text is shown


Solution

  • This PostScript code works for me:

    %!
    /C60 {/Courier findfont 60 scalefont setfont 30 700 moveto} def
    
    /myfrm
       <<
         /Matrix [ 2 3 .1  2 0 0 ]  
         /PaintProc
            {
               /Helvetica findfont 24 scalefont setfont
               10 10 moveto
               (Your name is Haider) show
            }
         /BBox [ 0 0 450 100]
         /FormType 1
      >> def
    
    C60 (Page 1) show myfrm execform showpage
    C60 (Page 2) show myfrm execform showpage
    C60 (Page 3) show myfrm execform showpage
    

    Is this what you're looking for?