Class: CPDF_Adapter
Source Location: /include/cpdf_adapter.cls.php
Class CPDF_Adapter
Class Overview
|
Implements interfaces:
PDF rendering interface
CPDF_Adapter provides a simple stateless interface to the stateful one provided by the Cpdf class. Unless otherwise mentioned, all dimensions are in points (1/72 in). The coordinate origin is in the top left corner, and y values increase downwards. See http://www.ros.co.nz/pdf/ for more complete documentation on the underlying Cpdf class.
Located in /include/cpdf_adapter.cls.php [line 60]
|
Properties
|
Methods
|
Property Summary
| static array; |
$PAPER_SIZES |
Dimensions of paper sizes in points |
Method Summary
| void |
add_named_dest() |
Add a named destination (similar to <a name="foo">...</a> in html) |
| void |
add_object() |
Adds a specified 'object' to the document |
| float |
get_height() |
Returns the PDF's height in points |
| string |
get_messages() |
Returns logging messages generated by the Cpdf class |
| int |
get_page_count() |
Returns the total number of pages in the document |
| float |
get_width() |
Returns the PDF's width in points |
| string |
output() |
Returns the PDF as a string |
| void |
page_text() |
Writes text at the specified x and y coordinates on every page |
| void |
stop_object() |
Stops the specified 'object' from appearing in the document. |
| void |
stream() |
Streams the PDF directly to the browser |
| float |
y() |
Remaps y coords from 4th to 1st quadrant |
| void |
_add_page_text() |
Add text to each page after rendering is complete |
Properties
Dimensions of paper sizes in points
Methods
CPDF_Adapter __construct(
[mixed
$paper = "letter"], [string
$orientation = "portrait"]
)
|
|
Class constructor
Parameters:
|
mixed |
$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') |
Class destructor
Deletes all temporary image files
void add_link(
string
$url, float
$x, float
$y, float
$width, float
$height
)
|
|
Add a link to the pdf
Parameters:
|
string |
$url: |
The url to link to |
|
float |
$x: |
The x position of the link |
|
float |
$y: |
The y position of the link |
|
float |
$width: |
The width of the link |
|
float |
$height: |
The height of the link |
Implementation of:
- Canvas::add_link()
- Add a link to the pdf
void add_named_dest(
string
$anchorname
)
|
|
Add a named destination (similar to <a name="foo">...</a> in html)
Parameters:
|
string |
$anchorname: |
The name of the named destination |
Implementation of:
- Canvas::add_named_dest()
- Add a named destination (similar to <a name="foo">...</a> in html)
void add_object(
int
$object, [string
$where = 'all']
)
|
|
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
Parameters:
|
int |
$object: |
|
|
string |
$where: |
|
API Tags:
void circle(
$x,
$y,
$r1,
$color, [
$width = null], [
$style = null], [
$fill = false], [
$blend = "Normal"], [
$opacity = 1.0]
)
|
|
Parameters:
|
|
$x: |
|
|
|
$y: |
|
|
|
$r1: |
|
|
|
$color: |
|
|
|
$width: |
|
|
|
$style: |
|
|
|
$fill: |
|
|
|
$blend: |
|
|
|
$opacity: |
|
Implementation of:
- Canvas::circle()
- Draws a circle at $x,$y with radius $r
Closes the current 'object'
API Tags:
void filled_rectangle(
$x1,
$y1,
$w,
$h,
$color, [
$blend = "Normal"], [
$opacity = 1.0]
)
|
|
Parameters:
|
|
$x1: |
|
|
|
$y1: |
|
|
|
$w: |
|
|
|
$h: |
|
|
|
$color: |
|
|
|
$blend: |
|
|
|
$opacity: |
|
Implementation of:
- Canvas::filled_rectangle()
- Draws a filled rectangle at x1,y1 with width w and height h
Returns the Cpdf instance
void get_font_height(
$font,
$size
)
|
|
Parameters:
Implementation of:
- Canvas::get_font_height()
- Calculates font height, in points
Returns the PDF's height in points
Returns logging messages generated by the Cpdf class
Returns the total number of pages in the document
Implementation of:
- Canvas::get_page_count()
- Returns the total number of pages
void get_text_width(
$text,
$font,
$size, [
$spacing = 0]
)
|
|
Parameters:
|
|
$text: |
|
|
|
$font: |
|
|
|
$size: |
|
|
|
$spacing: |
|
Implementation of:
- Canvas::get_text_width()
- Calculates text size, in points
Returns the PDF's width in points
void image(
$img_url,
$img_type,
$x,
$y,
$w,
$h
)
|
|
Parameters:
|
|
$img_url: |
|
|
|
$img_type: |
|
|
|
$x: |
|
|
|
$y: |
|
|
|
$w: |
|
|
|
$h: |
|
Implementation of:
- Canvas::image()
- Add an image to the pdf.
void line(
$x1,
$y1,
$x2,
$y2,
$color,
$width, [
$style = array()], [
$blend = "Normal"], [
$opacity = 1.0]
)
|
|
Parameters:
|
|
$x1: |
|
|
|
$y1: |
|
|
|
$x2: |
|
|
|
$y2: |
|
|
|
$color: |
|
|
|
$width: |
|
|
|
$style: |
|
|
|
$blend: |
|
|
|
$opacity: |
|
Implementation of:
- Canvas::line()
- Draws a line from x1,y1 to x2,y2
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.
API Tags:
string output(
[
$options = null]
)
|
|
Returns the PDF as a string
Parameters:
Implementation of:
- Canvas::output()
- Returns the PDF as a string
void page_text(
float
$x, float
$y, string
$text, string
$font, float
$size, [array
$color = array(0,0,0)], [float
$adjust = 0], [float
$angle = 0], [
$blend = "Normal"], [
$opacity = 1.0]
)
|
|
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.
Parameters:
|
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 |
|
|
$blend: |
|
|
|
$opacity: |
|
void polygon(
$points,
$color, [
$width = null], [
$style = array()], [
$fill = false], [
$blend = "Normal"], [
$opacity = 1.0]
)
|
|
Parameters:
|
|
$points: |
|
|
|
$color: |
|
|
|
$width: |
|
|
|
$style: |
|
|
|
$fill: |
|
|
|
$blend: |
|
|
|
$opacity: |
|
Implementation of:
- Canvas::polygon()
- Draws a polygon
void rectangle(
$x1,
$y1,
$w,
$h,
$color,
$width, [
$style = array()], [
$blend = "Normal"], [
$opacity = 1.0]
)
|
|
Parameters:
|
|
$x1: |
|
|
|
$y1: |
|
|
|
$w: |
|
|
|
$h: |
|
|
|
$color: |
|
|
|
$width: |
|
|
|
$style: |
|
|
|
$blend: |
|
|
|
$opacity: |
|
Implementation of:
- Canvas::rectangle()
- Draws a rectangle at x1,y1 with width w and height h
void reopen_object(
int
$object
)
|
|
Reopens an existing 'object'
Parameters:
|
int |
$object: |
the ID of a previously opened object |
API Tags:
void set_page_count(
int
$count
)
|
|
Sets the page count
Parameters:
Implementation of:
- Canvas::set_page_count()
- Sets the total number of pages
void set_page_number(
int
$num
)
|
|
Sets the current page number
Parameters:
void stop_object(
int
$object
)
|
|
Stops the specified 'object' from appearing in the document.
The object will stop being displayed on the page following the current one.
Parameters:
void stream(
string
$filename, [array
$options = null]
)
|
|
Streams the PDF directly to the browser
Parameters:
|
string |
$filename: |
the name of the PDF file |
|
array |
$options: |
associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0 |
Implementation of:
- Canvas::stream()
- Streams the PDF directly to the browser
void text(
$x,
$y,
$text,
$font,
$size, [
$color = array(0,0,0)], [
$adjust = 0], [
$angle = 0], [
$blend = "Normal"], [
$opacity = 1.0]
)
|
|
Parameters:
|
|
$x: |
|
|
|
$y: |
|
|
|
$text: |
|
|
|
$font: |
|
|
|
$size: |
|
|
|
$color: |
|
|
|
$adjust: |
|
|
|
$angle: |
|
|
|
$blend: |
|
|
|
$opacity: |
|
Implementation of:
- Canvas::text()
- Writes text at the specified x and y coordinates
Remaps y coords from 4th to 1st quadrant
Parameters:
API Tags:
Add text to each page after rendering is complete
API Tags:
string _convert_gif_to_png(
$image_url
)
|
|
Convert a GIF image to a PNG image
Parameters:
API Tags:
| Return: | The url of the newly converted image |
| Access: | protected |
void _set_fill_color(
array
$color
)
|
|
Sets the fill colour
See Style::set_colour() for the format of the colour array.
Parameters:
API Tags:
void _set_fill_transparency(
string
$mode, float
$opacity
)
|
|
Sets fill transparency
Parameters:
|
string |
$mode: |
the blending mode to use |
|
float |
$opacity: |
0.0 fully transparent, 1.0 fully opaque |
API Tags:
| See: | Cpdf::setFillTransparency()
Valid blend modes are (case-sensitive):
Normal, Multiply, Screen, Overlay, Darken, Lighten, ColorDogde, ColorBurn, HardLight, SoftLight, Difference, Exclusion |
| Access: | protected |
void _set_line_style(
float
$width, string
$cap, string
$join, array
$dash
)
|
|
Sets the line style
Parameters:
|
float |
$width: |
width |
|
string |
$cap: |
cap |
|
string |
$join: |
join |
|
array |
$dash: |
dash |
API Tags:
void _set_line_transparency(
string
$mode, float
$opacity
)
|
|
Sets line transparency
Parameters:
|
string |
$mode: |
the blending mode to use |
|
float |
$opacity: |
0.0 fully transparent, 1.0 fully opaque |
API Tags:
| See: | Cpdf::setLineTransparency()
Valid blend modes are (case-sensitive):
Normal, Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn, HardLight, SoftLight, Difference, Exclusion |
| Access: | protected |
void _set_stroke_color(
array
$color
)
|
|
Sets the stroke colour
See Style::set_colour() for the format of the color array.
Parameters:
API Tags:
|
|