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.
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.
In Lua, it is necessary to call function cdluapdf_open() after a call to function cdlua_open(), apart from linkediting with the "cdluapdf" library.
Behavior of Functions
Control
- Play: does nothing, returns CD_ERROR.
- Flush: changes to a new page, preserving the previous one.
- Clear: does nothing.
Coordinate System & Clipping
- UpdateYAxis: does nothing.
- Complex Regions: not supported.
Attributes
- Background does nothing, returns CD_WHITE.
- BackOpacity: does nothing, returns CD_TRANSPARENT.
- WriteMode: does nothing, returns CD_REPLACE.
- Hatch: is always opaque.
- Stipple: is always opaque.
- Font: the old "System" font is mapped to the "Courier" font. For the PDF core fonts styles are added to the font name, for other fonts styles are simulated by PDFlib. Underline and Strikeout are supported. Following is the core fonts:
Courier, Courier-Bold, Courier-Oblique, Courier-BoldOblique, Helvetica, Helvetica-Bold, Helvetica-Oblique, Helvetica-BoldOblique, Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic, Symbol, ZapfDingbats
Colors
- GetColorPlanes: returns 24.
- Palette: does nothing.
Client Images
- GetImageRGB: does nothing.
- PutImageMap: stores an RGB image.
Primitives
- Pixel: does not exist in PDF, is simulated using a circle with radius=1.
- Floating point primitives are supported.
- Filled primitves do not include the line at the edges of the filled area.
Server Images
- All functions do nothing.
Exclusive Attributes
- "POLYHOLE": defines the index of the 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. Default: NULL.
- "HATCHBOXSIZE": defines the size of smallest hatch box pattern. This affects the spacing between the hatch lines. The value passed must be a string containing an integer ("%d"). If the value of the attribute passed is NULL, the value is rest to the default. When consulted returns the current value ("%d"). Default: "8".
- "ROTATE": allows the usage of 1 angle and 1 coordinate (x, y), that define a global rotation transformation centered in the specified coordinate. Use 1 real and 2 integer values inside a string ("%g %d %d" = angle x y).