CD - Canvas Draw

PostScript Driver (cdps.h)

This drivers allows generating a PostScript file. This format was created to be a high-quality graphics language for printers and is currently supported by several printers. If your printer supports PostScript, you can send the file generated by the driver directly to the printer port. Usually, the filename has an extension .PS or .EPS. The driver generates level-2 PostScript, therefore some PostScript viewers might present errors. The format's copyrights are property of Adobe Systems.


Use

The file is created and opened by calling function cdCreateCanvas(CD_PS, Data), in which Data contains the filename and canvas dimensions. This function opens the file and writes its header. Then, other functions in the CD library can be called as usual. The Data parameter string has the following format:

"filename -p[paper] -w[width] -h[height] -l[left] -r[right] -b[bottom] -t[top] -s[resolution] [-e] [-g] [-o] [-1] d[margin]" or in C
"%s -p%d -w%g -h%g -l%g -r%g -b%g -t%g -s%d -e -o -1 -g -d%g"

Any amount of such canvases may exist simultaneously. It is important to note that a call to function cdKillCanvas is required to close the file properly.

Paper Size - The default paper size is A4. It is possible to change it by using one of the predefined sizes - CD_A0, CD_A1, CD_A2, CD_A3, CD_A4, CD_A5, CD_LETTER and CD_LEGAL - with parameter "-p". It is also possible to define a paper in a particular size by using parameters "-w" e "-h". Values are provided in millimeters.

Default Paper Sizes
  Width (mm) Length (mm)
A0 841 1187
A1 594 841
A2 420 594
A3 297 420
A4 210 297
A5 148 210
Letter 216 279
Legal 216 356

Margins - The margins are controlled by parameters "-l" "-r" "-t" and "-b" (left, right, top, bottom). Values are provided in millimeters. Default margins are 25.4 mm to all parameters. You can draw only inside the margins.

Resolution - Resolution is used to convert values from millimeters to pixels (the same as points, but the number of points is per inch - DPI). Use parameter "-s" to configure the resolution. The default value is 300 DPI.

Orientation - The page can be oriented as portrait or landscape. The default value is portrait, but when the parameter "-o" is used, the horizontal and vertical values are switched.

EPS - The PostScript file can be in an Encapsulated PostScript format. For such, simply specify the parameter "-e". It is useful for other applications to import the PostScript file. You can define the margins of the bounding box by means of parameter "-d", in millimeters.

Debug - Parameter "-g" adds a series of comments to the PS file, making the beginning and end of a command from the CD library explicit. It is useful only for those who understand PostScript and wish to identify a problem. It considerably increases the file size.

Level 1 - Parameter "-1" forces the driver to generate a level-1 PostScript. In this case, pattern, stipple and hatch are not supported.

Pages - Use function cdFlush to change to a new page. The previous page will not be changed.


Behavior of Functions

Control

  • cdPlay: does nothing, returns CD_ERROR.
  • cdFlush: changes to a new page, preserving the previous one. Does nothing in EPS mode.
  • cdClear: does nothing.

Coordinate System 

Attributes

Colors

Client Images

Primitives

  • cdMark: is simulated.
  • cdPixel: does not exist in PS, is simulated using a circle with ray 1.

Server Images

  • All functions do nothing.

WC

  • Implemented directly in the driver.

Exclusive Attributes

  • "POLYHOLE": informs the driver the position of a hole in the closed polygon to be drawn next. Can be called several times to define several holes. The value passed must be a string containing an integer. If the value of the attribute passed is NULL, all holes will no longer be considered. 
  • "CMD": saves a string directly to the file. Allows adding PostScript commands to the file generated by the CD library.