CD - Canvas Draw

CD_PDF - PDF Driver (cdpdf.h)

This drivers allows generating a PDF file. This format developed for representing documents in a manner that is independent of the original application software, hardware, and operating system used to create those documents. The format's copyrights are property of Adobe Systems.

This driver is very similar to the PS driver but it uses the PDFlib library to generate the PDF (http://www.pdflib.com/). There are two PDFlib licenses available, one commercial and one free with a flexible license, see PDFlib Lite License. The CD_PDF driver works with both versions, but by default uses the PDF Lite version code. The configuration of the PDF Lite code excludes other image file formats. 

PDFlib Copyright (c) 1997-2005 Thomas Merz and PDFlib GmbH. All rights reserved. Applications that use this driver are subject to the PDFlib GmbH License Agreement.


Use

The file is created and opened by calling function cdCreateCanvas(CD_PDF, 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] -s[resolution] [-o]" or in C
"%s -p%d -w%g -h%g -s%d -o"

The filename must be inside double quotes (") if it has spaces. 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

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.


Behavior of Functions

Control

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

Coordinate System & Clipping

Attributes

  • cdBackground does nothing, returns CD_WHITE.
  • cdBackOpacity: does nothing, returns CD_TRANSPARENT.
  • cdWriteMode: does nothing, returns CD_REPLACE.
  • cdNativeFont: the font string describer has the following format:
    "fontname, size [style] [-k] [-u]", where fontname is the name of the font in Windows (notice the comma after the font name), size is given in points or in pixels, style is the same as cdFont, -u means underline and -k means strikethrough, or "-d" to show the font-selection dialogue box. However, this function also accepts the font string used by the WINFONT attribute of the IUP library.
  • cdHatch: is always opaque.
  • cdStipple: is always opaque.
  • cdFont: see the font mapping table for the equivalence used to map CD fonts into PS fonts:
Font Mapping
CD Fonts PS Fonts
CD_SYSTEM Courier
CD_COURIER Courier
CD_TIMES_ROMAN Times-Roman
CD_HELVETICA Helvetica

Colors

Client Images

Primitives

  • cdMark: is simulated.
  • cdPixel: does not exist in PDF, is simulated using a circle with radius=1.

Server Images

  • All functions do nothing.

Exclusive Attributes

  • "POLYHOLE": defines the index of a vertex where there is a hole in a closed polygon. It will affect the next cdEnd. Can be called several times between cdBegin and cdEnd to define holes. The value passed must be a string containing an integer ("%d"). If the value of the attribute passed is NULL, all holes will no longer be considered. When consulted returns the current number of holes ("%d"). It can have a maximum of 500 holes.