Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You know how to use files in C#, right? A very simple way to do it would be to just have your program create a new <code>ofstream</code> or whatever C# calls it, naming it whatever.ps, and just appending strings to the file. Its really quite easy to learn, although I'd recommend actually getting a print copy of the Postscript Language Reference manual if you are going to do it that way. Even though you can get an electronic version for free, it really isn't as useful as a print copy unless you have more than one monitor.</p> <p>For instance, to draw a 1" square centered at the middle of a portrait-oriented piece of letter-size paper in C++, I'd do something like:</p> <pre><code>myFile &lt;&lt; "%!PS-Adobe-2.0 \n" //header block &lt;&lt; "%%Creator: INSERT YOUR NAME HERE \n" &lt;&lt; "%%Title: FILENAME.ps \n" &lt;&lt; "%%Pages: 1 \n" &lt;&lt; "%%PageOrder: Ascend \n" &lt;&lt; "%%BoundingBox: 0 0 612 792 \n" &lt;&lt; "%%DocumentPaperSizes: Letter \n" &lt;&lt; "%%EndComments \n" myFile &lt;&lt; "&lt;&lt; /PageSize [612 792] &gt;&gt; setpagedevice \n" //page setup &lt;&lt; "396 306 translate \n" //set (0,0) to center of page myFile &lt;&lt; "-36 -36 72 72 rectfill \n" //the rectangle at last! </code></pre> <p>You would need to translate that into whatever language you are using, though. Also, to be more readable, you might put the header block into its own function. In fact, you don't even need the newlines at the end of each string, except in the header block.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload