Interface Canvas

Description

Main rendering interface

Currently only CPDF_Adapter and PDFLib_Adapter implement this interface.

Implementations should measure x and y increasing to the left and down, respectively, with the origin in the top left corner. Implementations are free to use a unit other than points for length, but I can't guarantee that the results will look any good.

Located in /include/canvas.cls.php (line 55)


	
			
Method Summary
void circle (mixed $x, mixed $y, float $r1, array $color, [float $width = null], [array $style = null], [bool $fill = false], float $x1, float $y1)
void filled_rectangle (float $x1, float $y1, float $w, float $h, array $color)
float get_font_height (string $font, float $size)
float get_text_width (string $text, string $font, float $size, float $spacing)
void image (string $img_url, string $img_type, float $x, float $y, int $w, int $h)
void line (float $x1, float $y1, float $x2, float $y2, array $color, float $width, [array $style = null])
void new_page ()
string output ()
void polygon (array $points, array $color, [float $width = null], [array $style = null], [bool $fill = false])
void rectangle (float $x1, float $y1, float $w, float $h, array $color, float $width, [array $style = null])
void set_page_count (int $count)
void stream (string $filename, [array $options = null])
void text (float $x, float $y, string $text, string $font, float $size, [array $color = array(0,0,0)], float $adjust, float $angle)
Methods
circle (line 164)

Draws a circle at x,y with radius $r1

See Style::munge_colour() for the format of the colour array. See Cpdf::setLineStyle() for a description of the $style parameter (aka dash)

void circle (mixed $x, mixed $y, float $r1, array $color, [float $width = null], [array $style = null], [bool $fill = false], float $x1, float $y1)
  • float $x1
  • float $y1
  • float $r1
  • array $color
  • float $width
  • array $style
  • bool $fill: Fills the circle if true
filled_rectangle (line 123)

Draws a filled rectangle at x1,y1 with width w and height h

See Style::munge_colour() for the format of the colour array.

void filled_rectangle (float $x1, float $y1, float $w, float $h, array $color)
  • float $x1
  • float $y1
  • float $w
  • float $h
  • array $color
get_font_height (line 215)

Calculates font height, in points

float get_font_height (string $font, float $size)
  • string $font
  • float $size
get_page_count (line 69)

Returns the total number of pages

int get_page_count ()
get_page_number (line 62)

Returns the current page number

int get_page_number ()
get_text_width (line 206)

Calculates text size, in points

float get_text_width (string $text, string $font, float $size, float $spacing)
  • string $text: the text to be sized
  • string $font: the desired font
  • float $size: the desired font size
  • float $spacing: word spacing, if any
image (line 179)

Add an image to the pdf.

The image is placed at the specified x and y coordinates with the given width and height.

void image (string $img_url, string $img_type, float $x, float $y, int $w, int $h)
  • string $img_url: the path to the image
  • string $img_type: the type (e.g. extension) of the image
  • float $x: x position
  • float $y: y position
  • int $w: width (in pixels)
  • int $h: height (in pixels)
line (line 93)

Draws a line from x1,y1 to x2,y2

See Style::munge_colour() for the format of the colour array. See Cpdf::setLineStyle() for a description of the format of the $style parameter (aka dash).

void line (float $x1, float $y1, float $x2, float $y2, array $color, float $width, [array $style = null])
  • float $x1
  • float $y1
  • float $x2
  • float $y2
  • array $color
  • float $width
  • array $style
new_page (line 223)

Starts a new page

Subsequent drawing operations will appear on the new page.

void new_page ()
output (line 238)

Returns the PDF as a string

string output ()
polygon (line 147)

Draws a polygon

The polygon is formed by joining all the points stored in the $points array. $points has the following structure:

  1. array(0 => x1,
  2. 1 => y1,
  3. ...
  4. );

See Style::munge_colour() for the format of the colour array. See Cpdf::setLineStyle() for a description of the $style parameter (aka dash)

void polygon (array $points, array $color, [float $width = null], [array $style = null], [bool $fill = false])
  • array $points
  • array $color
  • float $width
  • array $style
  • bool $fill: fill Fills the polygon if true
rectangle (line 110)

Draws a rectangle at x1,y1 with width w and height h

See Style::munge_colour() for the format of the colour array. See Cpdf::setLineStyle() for a description of the $style parameter (aka dash)

void rectangle (float $x1, float $y1, float $w, float $h, array $color, float $width, [array $style = null])
  • float $x1
  • float $y1
  • float $w
  • float $h
  • array $color
  • float $width
  • array $style
set_page_count (line 76)

Sets the total number of pages

void set_page_count (int $count)
  • int $count
stream (line 231)

Streams the PDF directly to the browser

void stream (string $filename, [array $options = null])
  • string $filename: the name of the PDF file
  • array $options: associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0
text (line 195)

Writes text at the specified x and y coordinates

See Style::munge_colour() for the format of the colour array.

void text (float $x, float $y, string $text, string $font, float $size, [array $color = array(0,0,0)], float $adjust, float $angle)
  • float $x
  • float $y
  • string $text: the text to write
  • string $font: the font file to use
  • float $size: the font size, in points
  • array $color
  • float $adjust: word spacing adjustment
  • float $angle: angle to write the text at, measured CW starting from the x-axis

Documentation generated on Fri, 04 Mar 2005 13:31:16 -0700 by phpDocumentor 1.3.0RC3