PostScript is the worldwide printing and imaging standard. It is used by print service providers, publishers, corporations, and government agencies around the globe. In short, PostScript is a complex programming language designed especially for printing graphics. See http://vrr.ucw.cz/doc/PLRM.pdf for complete reference. The structuring information is maintained in the form of the DSC comments inside the PostScript code, see http://vrr.ucw.cz/doc/DSC.pdf for complete definition. Without these additional informations, the document structure is nearly unrecognizable. VRR PostScript output is fully conforming to DSC conventions.
There are libraries which allow the programmer to output valid PostScript code. However, we decided to write our exporter by hand, which gives us more control on what happens in the code.
In the beginning of the output, the exporter stores the DSC header and defines its own set of command shortcuts to minimize the output size. Then the font data are stored. PostScript requires special font formats. The Type1 fonts are supported but the TrueTypes are not and must be converted into a Type42 font, which is done by FONTLIB. See FONTLIB. Every used font is dumped only once. The exporter is able to omit the font files and write DSC commands instead, which should cause loading of the specified fonts by the PostScript viewer and interpreter.
The export itself is quite straightforward. The exporter walks through the GO list, outputs the graphical environment setup (stroke color, fill color, line caps, etc.) and then the appropriate command with arguments. The document is exported as one PostScript file and every TLO object is exported as a separate document page. Every object in the output is surrounded by the gsave and grestore PostScript commands, so that the programmer can freely change graphical output properties without bothering with restoring them. The same applies to every page, which is surrouned by save and restore commands.
We should also mention that sometimes an object we are exporting is not supported by PostScript object set and we approximate it with Bézier curves, which is done by GEOMLIB (see GEOMLIB).
The exporter source code is in the file export/ps.c.
An encapsulated PostScript file is a PostScript language program describing the appearance of a single page. Typically, the purpose of the EPS file is to be included, or “encapsulated”, in another PostScript language page description. The EPS file can contain any combination of text, graphics, and images, and it is the same as any other PostScript language page description with only a few restrictions. See http://vrr.ucw.cz/doc/EPSF_Spec.pdf for complete reference.
The VRR PostScript exporter supports an EPS export variant which of course exports valid EPS file containing only one page. Consult the exporter source code for details how the PS and EPS outputs differs.