How do I create a "ps." file containing my hand written code on a mac?

I want to draw mathematical pictures by writing postscript code. I've done this on my windows machine. The text editors on my mac will not let me save a file as a ".ps" file. I tried the advice given by apple support, of selecting "save to .ps" in the print menu, but this does not produce a ".ps" file containing my code. It produces a ".ps" file that contains code for producing a page containing my code, so when I view it I just see my code "200 200 moveto", etc., instead of the picture the code is supposed to draw. Any help?

iMac, iOS 9.3.2

Posted on Jun 28, 2016 9:08 AM

Reply
4 replies

Jun 28, 2016 2:34 PM in response to kent swearingen

You can use the Grapher application (Launchpad : Other : Grapher) to input your equations and visualize them too. Select the equation, or the graph, and then right-click, selecting copy as eps. In the Terminal, you can employ different constructs to write to ps, open the ps in TextEdit (plain text), or even Preview.

# only type the blue text

# write the eps that was copied from Grapher — from the clipboard to a postscript file

$ pbpaste -Prefer ps > foo.ps

# open the eps in TextEdit (default) as postscript

$ pbpaste -Prefer ps | open -f

# open the eps in Preview (as converted to PDF)

$ pbpaste -Prefer ps | open -f -a Preview


Here is result for the Torus Knot Grapher demo using the above technique.

User uploaded file

Jun 28, 2016 2:34 PM in response to kent swearingen

Use a text editor that can create/save to plain text i.e. as a .txt file.


This can be done in TextEdit by setting: Preferences > New Document > Format to Plain Text.


When saving (or after saving) simply rename the file to end with .ps.


I would also guess that sticking to Unicode(UTF-8) or ASCII as the text encoding is the safest bet to avoid character encoding issues.


The saved .ps file should now be displayed as rendered postscript in Preview (as Preview knows how to draw the postscript instructions) and show up as postscript "source" code in TextEdit (when the .ps file is dragged onto TextEdit or opened from TextEdit).


The above solution worked fine for me using the "Hello world" example from the english Wikipedia page.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How do I create a "ps." file containing my hand written code on a mac?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.