Class: I2CE PDF: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
This article desrcibes the class | This article desrcibes the class ''I2CE_PDF''. | ||
*Extends the class: tcpdf. | *Extends the class: tcpdf. | ||
*Location: Part of the module [[iHRIS Module List#textlayout|textlayout]] in the package [https://launchpad.net/textlayout TextLayout Tools] | *Location: Part of the module [[iHRIS Module List#textlayout|textlayout]] in the package [https://launchpad.net/textlayout TextLayout Tools] | ||
*Source: Defined in the file [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0.0-release/annotate/head:/lib/I2CE_PDF.php lib/I2CE_PDF.php] | *Source: Defined in the file [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.0.0-release/annotate/head:/lib/I2CE_PDF.php lib/I2CE_PDF.php] | ||
==Variables== | ==Variables== | ||
===$print_header=== | ===$print_header=== |
Revision as of 22:15, 16 October 2009
This article desrcibes the class I2CE_PDF.
- Extends the class: tcpdf.
- Location: Part of the module textlayout in the package TextLayout Tools
- Source: Defined in the file lib/I2CE_PDF.php
Variables
$print_header
true prints header @access protected
- Type: protected If $print_header
true prints footer. @access protected
- Type: protected If $print_footer
$header_width
width (0 = full page width). @access protected
- Type: protected Header $header_width
$header_logo
image logo. @access protected
- Type: protected Header $header_logo
$header_logo_width
image logo width in mm. @access protected
- Type: protected Header $header_logo_width
$header_font
font. @access protected
- Type: protected Header $header_font
font. @access protected
- Type: protected Footer $footer_font
$header_title
to print as title on document header. @access protected
- Type: protected String $header_title
$header_string
to print on document header. @access protected
- Type: protected String $header_string
$header_margin
distance between header and top page margin. @access protected
- Type: protected Minimum $header_margin
distance between footer and bottom page margin. @access protected
- Type: protected Minimum $footer_margin
$original_lMargin
left margin value @access protected @since 1.53.0.TC013
- Type: protected ginal $original_lMargin
$original_rMargin
right margin value @access protected @since 1.53.0.TC013
- Type: protected ginal $original_rMargin
$enc
protected @var I2CE_Encoding enc
- Type: protected $enc
$text_table
protected @var I2CE_TextTable $text_table
- Type: protected $text_table
$hyphen
protected @var I2CE_Hyphen hyphen -- a hyphenation dictionary
- Type: protected $hyphen
$font_metric
protected @var array of I2CE_FontMetric font_metrics
- Type: protected $font_metric
$running_header
True if we want the header of a table repeated on each page
- Type: protected n $running_header
$row_spacing
-- the spacing (in points) between succesive rows of text in a table
- Type: protected numeric $row_spacing
$adobe_standard_encodings
of I2CE_Encodings $adobe_standard_encodings
- Type: protected y $adobe_standard_encodings
$min_cell_width
the minimum number of points we want minimially as the width of a cell in a table
- Type: protected nt $min_cell_width
$header_fill_color
of int $header_fill_color for the fill color of the header row of a table
- Type: protected y $header_fill_color
$header_text_color
of int $header_text_color for the text color of the header row of a table
- Type: protected y $header_text_color
$data_fill_color
of int $header_fill_color for the fill color of the header row of a table
- Type: protected y $data_fill_color
$table_framing_color
of int $table_framing_color the color used to draw the frame for the table
- Type: protected y $table_framing_color
$data_text_color
of int $header_text_color for the text color of the header row of a table
- Type: protected y $data_text_color
$glyph_list
- Type: protected $glyph_list
Methods
AddCoreFontMetrics()
Add a Core PDF Font
- Signature: protected function AddCoreFontMetrics($family,$style)
Parameters:
AddFontByTTFFile()
- Signature: public function AddFontByTTFFile($family,$style,$ttf_file)
Parameters:
- $family
- $style
- $ttf_file
AddPage()
Adds a new page to the document. If a page is already present, the Footer() method is called first to output the footer. Then the page is added, the current position set to the top-left corner according to the left and top margins, and Header() is called to display the header. The font which was set before calling is automatically restored. There is no need to call SetFont() again if you want to continue with the same font. The same is true for colors and line width. The origin of the coordinate system is at the top-left corner and increasing ordinates go downwards. @since 1.0 @see TCPDF(), Header(), Footer(), SetMargins()
- Signature: public function AddPage($orientation)
Parameters:
- string $orientation
Page orientation. Possible values are (case insensitive):- P or Portrait
- L or Landscape
- Default Value:
Cell()
- Signature: public function Cell($w,$h,$txt,$border,$ln,$align,$fill,$link)
Parameters:
- $w
- $h
- Default Value: 0
- $txt
- Default Value:
- $border
- Default Value: 0
- $ln
- Default Value: 0
- $align
- Default Value:
- $fill
- Default Value: 0
- $link
- Default Value:
DisplayTextTableRow()
Draws a Text Table Row using wordwrapped rows @param array of array of strings $row_data. first index is column, second index is the text row in the cell @param array of numeric $widths in user units
- Signature: protected function DisplayTextTableRow($row_data,$widths,$h_user,$border,$align,$fill)
Parameters:
- $row_data
- $widths
- numeric $h_user
the height in user units - $border
- $align
- $fill
Error()
- Signature: public function Error($msg,$level)
Parameters:
- $msg
- $level
- Default Value: E_WARNING
GetStringWidth()
- Signature: public function GetStringWidth($s)
Parameters:
- $s
GetTableWidths()
Set the widths of the columns last used in the table
- Signature: public function GetTableWidths()
GetTextTable()
Get the TextTable object
- Signature: public function GetTextTable()
- Returns: TextTable
Header()
This method is used to render the page header.
- Signature: public function Header()
MakeTable()
Given a 2-dimensional table of string prints out a 'fancy' table @param float $w width of the table, 0 goes to right margin in user units @param float $h height of each row of text in user units @param array $text_table 2 dimensional array of text (indexing is [$row][$col]) .. Row has to be numeric sequential starting at 0. Column does not is already set, non null > 0 is the maximum table width
- 0: no border (default)
- 1: frame
Possible values are:
- 0: to the right
- 1: to the beginning of the next line [DEFAULT]
- 2: below
- Signature: public function MakeTable($text_table_data,$border,$max_table_width,$align_data,$header,$align_header,$ln)
Parameters:
- $text_table_data
- mixed $border
Indicates if borders must be drawn around the cell block. The value can be:- Default Value: 0
- numeric $max_table_width
the maximum table width -- 0 fill the table to the right margin, null use the value as it- Default Value: 0
- $align_data
- Default Value: 'C'
- int $header
: 0 no header, 1 has a header, 2 has a header and the header should repeat on a page break- Default Value: 1
- $align_header
- Default Value: 'L'
- int $ln
Indicates where the current position should go after the call.- Default Value: 1
SetAutoTableWidthStyle()
Set the alogorithm used to determine column widths
- Signature: public function SetAutoTableWidthStyle($style)
Parameters:
- string $style
Valid values are 'All', 'Header', and 'Explicit'
SetFont()
Sets the font used to print character strings. It is mandatory to call this method at least once before printing text or the resulting document would not be valid. The font can be either a standard one or a font added via the AddFont() method. Standard fonts use Windows encoding cp1252 (Western Europe). The method can be called before the first page is created and the font is retained from page to page. If you just wish to change the current font size, it is simpler to call SetFontSize().
Note: for the standard fonts, the font metric files must be accessible. There are three possibilities for this:
- They are in the current directory (the one where the running script lies)
- They are in one of the directories defined by the include_path parameter
- They are in the directory defined by the FPDF_FONTPATH constant
Example for the last case (note the trailing slash):
define('FPDF_FONTPATH','/home/www/font/'); require('tcpdf.php'); //Times regular 12 $pdf->SetFont('Times'); //Arial bold 14 $pdf->SetFont('Arial','B',14); //Removes bold $pdf->SetFont(''); //Times bold, italic and underlined 14 $pdf->SetFont('Times','BIU');
If the file corresponding to the requested font is not found, the error "Could not include font metric file" is generated. @since 1.0 @see AddFont(), SetFontSize(), Cell(), MultiCell(), Write()
- Signature: public function SetFont($family,$style,$size)
Parameters:
- string $family
Family font. It can be either a name defined by AddFont() or one of the standard families (case insensitive):- Courier (fixed-width)
- Helvetica or Arial (synonymous; sans serif)
- Times (serif)
- Symbol (symbolic)
- ZapfDingbats (symbolic)
- string $style
Font style. Possible values are (case insensitive):- empty string: regular
- B: bold
- I: italic
- U: underline
- Default Value:
- float $size
Font size in points. The default value is the current size. If no size has been specified since the beginning of the document, the value taken is 12- Default Value: 0
SetFontSize()
Defines the size of the current font. @since 1.0 @see SetFont()
- Signature: public function SetFontSize($size)
Parameters:
- float $size
The size (in points)
SetHyphenationDictionary()
set the hyphenation dictionary used for text tables
- Signature: public function SetHyphenationDictionary($hyphen)
Parameters:
- I2CE_Hyphen $hyphen
SetLineSpacing()
Set the spacing between rows of the table
- Signature: public function SetLineSpacing($spacing)
Parameters:
- numeric $spacing
number to multiply the text height by to get the spacing
SetMaxTableWidth()
Set the maximum width of the table width
- Signature: public function SetMaxTableWidth($width)
Parameters:
- numeric $width
in user units
SetMinTableCellWidth()
Set the minimum cell width of the table
- Signature: public function SetMinTableCellWidth($width)
Parameters:
- numeric $width
SetRunningHeader()
Set a running header for tables that span multiple pages
- Signature: public function SetRunningHeader($running_header)
Parameters:
- boolean $running_header
true to repeat the header
SetTableColSpacing()
Set the spacing between columns of the table
- Signature: public function SetTableColSpacing($spacing)
Parameters:
- numeric $spacing
SetTableDataFillColor()
Set the data fill color for a table @param array of $int -- the rgb values
- Signature: public function SetTableDataFillColor($color)
Parameters:
- $color
SetTableDataTextColor()
Set the data text color for a table @param array of $int -- the rgb values
- Signature: public function SetTableDataTextColor($color)
Parameters:
- $color
SetTableFramingColor()
Set the framing color for a table @param array of $int -- the rgb values
- Signature: public function SetTableFramingColor($color)
Parameters:
- $color
SetTableHeaderFillColor()
Set the header of a table's fill color @param array of $int -- the rgb values
- Signature: public function SetTableHeaderFillColor($color)
Parameters:
- $color
SetTableHeaderTextColor()
Set the header of a table's text color @param array of $int -- the rgb values
- Signature: public function SetTableHeaderTextColor($color)
Parameters:
- $color
SetTableWitdths()
Set the widths of the columns used in the table explicitly @parma array of number $widths -- the column widths Note: setting table width will set the table width style to explicit
- Signature: public function SetTableWitdths($widths)
Parameters:
- $widths
SetWordWrapAlgorithm()
Set the alogorithm used to determine word-wrapping
- Signature: public function SetWordWrapAlgorithm($algorithm)
Parameters:
- String $algorithm
__construct()
This is the class constructor. It allows to set up the page format, the orientation and the measure unit used in all the methods (except for the font sizes). @param I2CE_Encoding $enc charset encoding for all input strings
- Signature: public function __construct($encoding,$orientation,$unit,$format)
Parameters:
- $encoding
- string $orientation
page orientation. Possible values are (case insensitive):- P or Portrait (default)
- L or Landscape
- Default Value: 'P'
- string $unit
User measure unit. Possible values are:- pt: point
- mm: millimeter (default)
- cm: centimeter
- in: inch
A point equals 1/72 of inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in that unit.- Default Value: 'mm'
- mixed $format
The format used for pages. It can be either one of the following values (case insensitive) or a custom format in the form of a two-element array containing the width and the height (expressed in the unit given by unit).- 4A0
- 2A0
- A0
- A1
- A2
- A3
- A4 (default)
- A5
- A6
- A7
- A8
- A9
- A10
- B0
- B1
- B2
- B3
- B4
- B5
- B6
- B7
- B8
- B9
- B10
- C0
- C1
- C2
- C3
- C4
- C5
- C6
- C7
- C8
- C9
- C10
- RA0
- RA1
- RA2
- RA3
- RA4
- SRA0
- SRA1
- SRA2
- SRA3
- SRA4
- LETTER
- LEGAL
- EXECUTIVE
- FOLIO
- Default Value: 'A4'
_escapetext()
Format a text string @access protected
- Signature: public function _escapetext($s)
Parameters:
- $s
_putfonts()
Adds fonts _putfonts @access protected
- Signature: protected function _putfonts()
_puttruetypeembedded()
Adds unicode fonts.
Based on PDF Reference 1.3 (section 5)
@access protected
@author Nicola Asuni
@since 1.52.0.TC005 (2005-01-05)
- Signature: protected function _puttruetypeembedded($font)
Parameters:
- $font
_textstring()
Format a text string @access protected
- Signature: protected function _textstring($s)
Parameters:
- $s
getAdobeStandardEncoding()
Get the I2CE_Encoding according to one of the standard adobe encodings
- Signature: protected function getAdobeStandardEncoding($encoding)
Parameters:
- $encoding
getDescription()
Setup the array the required fields for the FontDescriptor entry The required fields are 'Ascent' 'Descent' 'CapHeight' 'Flags' 'FontBBox' 'ItalicAngle' 'StemV' 'MissingWidth'
- Signature: protected function getDescription($fm,$uses_adobe_standard_encoding)
Parameters:
- $fm
- $uses_adobe_standard_encoding
getFontKey()
get the fontkey associated to a fmaily and style
- Signature: protected function getFontKey($family,$style)
- Returns: string
Parameters:
loadGlyphList()
- Signature: protected function loadGlyphList()
load_file()
- Signature: protected function load_file($category,$file_name)
Parameters:
- $category
- $file_name
setHeaderData()
Set header data. @param string $ln header image logo
- Signature: public function setHeaderData($logo,$lw,$ht,$hs)
Parameters:
- $logo
- Default Value: ""
- string $lw
header image logo width in mm- Default Value: 0
- string $ht
string to print as title on document header- Default Value: ""
- string $hs
string to print on document header- Default Value: ""
setHeaderMargin()
Set header margin. (minimum distance between header and top page margin)
- Signature: public function setHeaderMargin($hm)
Parameters:
- int $hm
distance in user units- Default Value: 10
setHeaderWidth()
Sets header width
- Signature: public function setHeaderWidth($w)
Parameters:
- int $w
width in user units. Value of 0 says to use all the avaiable width- Default Value: 0
setPrintHeader()
Set a flag to print page header.
- Signature: public function setPrintHeader($val)
Parameters:
- boolean $val
set to true to print the page header (default), false otherwise.- Default Value: true