Class constructor
CPDF_Adapter
__construct
([string $paper = "letter"], [string $orientation = "portrait"])
-
string
$paper: The size of paper to use in this PDF (CPDF_Adapter::$PAPER_SIZES)
-
string
$orientation: The orienation of the document (either 'landscape' or 'portrait')
Adds a specified 'object' to the document
$object int specifying an object created with CPDF_Adapter::open_object(). $where can be one of:
- 'add' add to current page only
- 'all' add to every page from the current one onwards
- 'odd' add to all odd numbered pages from now on
- 'even' add to all even numbered pages from now on
- 'next' add the object to the next page only
- 'nextodd' add to all odd numbered pages from the next one
- 'nexteven' add to all even numbered pages from the next one
void
add_object
(int $object, [string $where = 'all'])
-
int
$object
-
string
$where
void
circle
(mixed $x, mixed $y, mixed $r1, mixed $color, [mixed $width = null], [mixed $style = null], [mixed $fill = false], [mixed $blend = "Normal"], [mixed $opacity = 1.0])
Closes the current 'object'
void
close_object
()
void
filled_rectangle
(mixed $x1, mixed $y1, mixed $w, mixed $h, mixed $color, [mixed $blend = "Normal"], [mixed $opacity = 1.0])
Returns the Cpdf instance
Cpdf
get_cpdf
()
void
get_font_height
(mixed $font, mixed $size)
Returns the PDF's height in points
float
get_height
()
Returns logging messages generated by the Cpdf class
string
get_messages
()
Returns the total number of pages in the document
int
get_page_count
()
Returns the current page number
int
get_page_number
()
void
get_text_width
(mixed $text, mixed $font, mixed $size, mixed $spacing)
Returns the PDF's width in points
float
get_width
()
void
image
(mixed $img_url, mixed $img_type, mixed $x, mixed $y, mixed $w, mixed $h)
void
line
(mixed $x1, mixed $y1, mixed $x2, mixed $y2, mixed $color, mixed $width, [mixed $style = array()], [mixed $blend = "Normal"], [mixed $opacity = 1.0])
Opens a new 'object'
While an object is open, all drawing actions are recored in the object, as opposed to being drawn on the current page. Objects can be added later to a specific page or to several pages.
The return value is an integer ID for the new object.
int
open_object
()
Returns the PDF as a string
string
output
()
Writes text at the specified x and y coordinates on every page
The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced with their current values.
See Style::munge_colour() for the format of the colour array.
void
page_text
(float $x, float $y, string $text, string $font, float $size, [array $color = array(0,0,0)], float $adjust, float $angle, [mixed $blend = "Normal"], [mixed $opacity = 1.0])
-
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
void
polygon
(mixed $points, mixed $color, [mixed $width = null], [mixed $style = array()], [mixed $fill = false], [mixed $blend = "Normal"], [mixed $opacity = 1.0])
void
rectangle
(mixed $x1, mixed $y1, mixed $w, mixed $h, mixed $color, mixed $width, [mixed $style = array()], [mixed $blend = "Normal"], [mixed $opacity = 1.0])
Reopens an existing 'object'
void
reopen_object
(int $object)
-
int
$object: the ID of a previously opened object
Sets the page count
void
set_page_count
(int $count)
Sets the current page number
void
set_page_number
(int $num)
Stops the specified 'object' from appearing in the document.
The object will stop being displayed on the page following the current one.
void
stop_object
(int $object)
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
void
text
(mixed $x, mixed $y, mixed $text, mixed $font, mixed $size, [mixed $color = array(0,0,0)], mixed $adjust, mixed $angle, [mixed $blend = "Normal"], [mixed $opacity = 1.0])
Remaps y coords from 4th to 1st quadrant
float
y
(float $y)
Sets the fill colour
See Style::set_colour() for the format of the colour array.
void
_set_fill_color
(array $color)
Sets fill transparency
void
_set_fill_transparency
(string $mode, float $opacity)
-
string
$mode: the blending mode to use
-
float
$opacity: 0.0 fully transparent, 1.0 fully opaque
Sets the line style
void
_set_line_style
(float $width, string $cap, string $join, array $dash)
-
float
$width: width
-
string
$cap: cap
-
string
$join: join
-
array
$dash: dash
Sets line transparency
void
_set_line_transparency
(string $mode, float $opacity)
-
string
$mode: the blending mode to use
-
float
$opacity: 0.0 fully transparent, 1.0 fully opaque
Sets the stroke colour
See Style::set_colour() for the format of the color array.
void
_set_stroke_color
(array $color)