home | news | install | contact | download | examples | docs | success stories

The examples on this page are all part of the example distribution which is separately available at sourceforge. The filename of each example is also linked to the list of available version in the CVS repository. If the example is also available for the python bindings, it will be linked too. All examples in python have been created by Stefan Schröder. The most current version is not necessarily the version creating the shown example page. Moreover the example in c may slightly differ from the python version.

Example 1: draw.c draw.py

This is the most complete example demonstrating many aspects of pslib. It contains many single boxes, each presenting a feature of pslib. If you are looking for a general overview or need example code which is not in one of the other more specific examples, you probably find it here. Anyway this is far from being complete and will be extended in the future.
PostScript file

Example 2: einstein.c einstein.py

This is basically a three pages text document. It was written in german bei Albert Einstein. It uses the font Schwabacher because of its many ligatures which is a perfect way to show some of pslib's enhanced text output features. The font itself does not contain any ligature information. That's why an encoding file is provided. The encoding vector itself is not used, but the ligatures in the head of the file. The font is also very buggy because the ligatures do not even have propper names. They are randomly placed all over the font replacing other glyphs. This explains the strange names of the ligatures in the encoding file. The text is set in two columns using hyphenation. Paragraphs are separated by a carrige return on a single line. The first line of a paragraph is indented. Paragraphs are also separated with extra space.
PostScript file Plain text

Example 3: psclock.c psclock.py

Those who know pdflib™ will probably know this example. It draws an analog clock on a single page showing the current time. The same example is shipped with pdflib. If you create several hundred pages then this example can somewhat serve as a simple benchmark. Just count the pages between two seconds. On my rather slow PowerPC 400 MHz it easily creates more than 400 pages a second. The number of pages can be set in the variable numpages in the C source file. This example also demonstrates page sizes different from the usual a4 or letter format (as it can be seen in the picture). It is accomplished with pdfmarks. A printer will not care about it but ghostscripts pdfwriter uses it for the size of the pdf pages.
PostScript file (2.6 MB)

Example 4: hyperlink.c hyperlink.py

pslib supports pdfmarks which allows to place code into the PostScript document which is disregarded by the printer but will be evaluated by Acrobat Distiller™ or Ghostscript when it is converted to PDF (see also example 3). Such pdfmarks can preserve features only supported by PDF in a PostScript document. This example is a two page document. The pages have different size and both have a bookmark. Page one contains several links which are displayed as boxes surrounded by a blue line when converted to PDF. The PostScript document just contains the text without the blue box.
PostScript file PDF file

Example 5: fontsample.c fontsample.py

Having a font and being able to use all its glyphs are two sides of a coin. If a glyph is actually available heavily depends on the used font encoding vector. pslib supports TeXBase1 and the fonts builtin encoding. This example creates a sample page for each given font using the builtin font encoding. All those cells without a glyph have not entry in the font encoding vector. You may try to use TeXBase1 instead which has reasonable set of glyphs used in western languages.
PostScript file

Example 6: spotcolor.c spotcolor.py

Professional publishing relies on spot colors. pslib has full support for it with a very simple approach based on the single function PS_makespotcolor(3). A spot color is an abitrary named color with an alternative representation in one the colorspaces 'rgb', 'cmyk', or 'gray'. The alternative color is only used on devices which cannot use the spot color itself. This is true for PostScript viewers and most printers. Separating a PostScript file with spot colors will have the expected result.
PostScript file

Example 7: ligatures.c ligatures.py

Good text output relies one ligatures which are available in many fonts. The most common ones are 'fi', 'ff', 'fl', 'ffi', and 'ffl'. Those are recognized by pslib automatically and used if the font has the glyphs for them. Many old german fonts like 'Alte Schwabacher' has many more ligatures, which may either be declared in the Adobe Font Metrics file or manually by a so called encoding file. The font used in this example is very broken. It does not declare any ligatures and spills the glyphs of the ligatures all over the fontencoding vector. Manual work had to be done to fix. Read the text of the example for some more information.
PostScript file

Example 8: pagehook.c pagehook.py

Quite often one needs to put something on each page in the document. This can be a big 'Draft' in light gray or a grid when designing the page layout. Theoretically, this could be done by a function being called at the begining of each page. Praktically, it complicates your code. This is very pagehooks enter the scene. pslib adds at the begining and end of a page some extra PostScript code into the document which calls a PostScript command called PslibPageBeginHook and PslibPageEndHook. By default these commands are defined to just throw the arguments away passed to them. By calling PS_include_file() before the first page, one can load raw PostScript code containing a new useful definitions for one or both commands. pslib ships with three different pagehooks already which are located in /usr/share/pslib. Be careful when you write your own hooks. They easily mess up your document because its raw PostScript without any error checking.
PostScript file

Example 9: shading.c shading.py

pslib can fill areas and stroke lines in solid colors, but it can do this with gradient fills as well. A gradient fill called shading can be used to fill any area surounded by a path. If used in combination with patterns it becomes like any color and is also available for drawing lines and text. There are currently only two types of gradient fills: 'axial' and 'radial'. The picture to the right has examples for both of them. A radial shading is good for making speres look three dimension.
PostScript file

Example 10: image.c image.py

This very simple example demonstrates how different image file types are included by pslib. If your local installation of pslib supports a file type, depends on if support for it was compiled in. The python example is a bit outdated.
PostScript file

Example 11: imagereuse.c

Images can become quite big and saving them into a PostScript file takes even more space. If the same image needs to be placed several times into the document, e.g. a company logo, the output file grows fast. To keep the file size small, image reuse was implemented and turned on by default since version 0.4.5 of pslib. Another advantage of reusable images is its possible use in templates, which was not allowed in earlier versions of pslib.
PostScript file

Example 12: pycal.py

This example is only available in python and prints a calendar for the current month.
PostScript file

Example 13: mandelbrot.py

This example is only available in python and prints a mandelbrot set.
PostScript file

  <uwe at steinmann.cx> SourceForgeLogo