Read Me
#
# README examples
# This file is part of python-pslib
# Written by Stefan Schroeder
#
To test python-pslib simply run
bash make_all.sh
in this directory. Some examples are slightly modified from the C-version.
E.g. I renamed the included pagehook-postscript files to *.inc, to be able
to easily remove all generated postscript files with *.ps without touching
the include files.
The command above will run all examples and create several postscript
files. Have a look at them to get acquainted with pslib's
capabilities. Study the python code to learn hwo a particular command
is used. Please do not assume to find an example for every pslib command.
We are working on it.
Have a nice day.
Stefan Schroeder
-= Using Python with PSlib =-
To create a postscript-file we need to take three steps:
1. Open the file and write some introductory information.
2. Draw and write some graphs and text.
3. Close the file.
An extensive minimal python script could look like this:
##########################################################
#!/usr/bin/python
import pslib
# Create an new instance
psdoc = pslib.PS_new()
# Open a file, pslib also allows to use an already open file handler.
pslib.PS_open_file(psdoc, "helloworld.ps") #
# Select a font, use the default encoding and do not embed.
#
foofont = ps.PS_findfont(psdoc, "Helvetica", "", 0)
# Start a new page in A4 format, units are postscript pixels.
pslib.PS_begin_page(psdoc, 596, 842)
# Letter would be 612x792.
# Print at coordinate (x=100|y=200)
pslib.PS_show_xy(psdoc, "Hello World", 100, 200)
# (0|0) is located at the bottom left corner.
# And some cleanup, don't omit this.
pslib.PS_end_page(psdoc)
pslib.PS_deletefont(psdoc, foofont)
pslib.PS_close(psdoc)
pslib.PS_delete(psdoc)
##########################################################
To learn more about postscript visit:
http://www.postscript.org/FAQs/language/FAQ.html
http://www.geocities.com/SiliconValley/5682/postscript.html
http://www.id.unizh.ch/publications/ps/