include/Sugarpdf/sugarpdf/sugarpdf.smarty.php
\SugarpdfSmarty
This is an helper class to generate PDF using smarty template.
You have to extend this class, set the templateLocation to your smarty template location and assign the Smarty variables ($this->ss->assign()) in the overriden preDisplay method (don't forget to call the parent).
- Parent(s)
- \Sugarpdf < \TCPDF
- Author
- bsoufflet
Constants
STRETCH_SCALE
= 1
- Inherited_from
- \Sugarpdf::STRETCH_SCALE
STRETCH_SCALE_FORCED
= 2
- Inherited_from
- \Sugarpdf::STRETCH_SCALE_FORCED
STRETCH_SPACING
= 3
- Inherited_from
- \Sugarpdf::STRETCH_SPACING
STRETCH_SPACING_FORCED
= 4
- Inherited_from
- \Sugarpdf::STRETCH_SPACING_FORCED
Properties
$aclAction= 'PDF_ACL_ACCESS'
PDF_ACL_ACCESS
Details- Type
- n/a
- Inherited_from
- \Sugarpdf::$$aclAction
$bean= 'null'
null
Details- Type
- n/a
- Inherited_from
- \Sugarpdf::$$bean
$errors= 'array()'
Any errors that occured this can either be set by the view or the controller or the model
Inherited from: \Sugarpdf::$$errorsarray()
Details- Type
- n/a
- Inherited_from
- \Sugarpdf::$$errors
$fileName= 'PDF_FILENAME'
PDF_FILENAME
Details- Type
- n/a
- Inherited_from
- \Sugarpdf::$$fileName
$smartyLn= 'true'
These 5 variables are use for the writeHTML method.
true
Details- Type
- n/a
- See
- \include/tcpdf/tcpdf.php
$sugarpdf_object_map= 'array()'
This array is meant to hold an objects/data that we would like to pass between the controller and the view. The bean will automatically be set for us, but this is meant to hold anything else.
Inherited from: \Sugarpdf::$$sugarpdf_object_maparray()
Details- Type
- n/a
- Inherited_from
- \Sugarpdf::$$sugarpdf_object_map
Methods
Cell(
$w, $h
=
0, $txt
=
'', $border
=
0, $ln
=
0, $align
=
'', $fill
=
0, $link
=
'', $stretch
=
0
)
:
void
Handle charset conversion and HTML entity decode. This method override the regular Cell() method to apply the prepare_string() function to the string to print in the PDF. The cell method is used by all the methods which print text (Write, MultiCell).
Name | Type | Description |
---|---|---|
$w | ||
$h | ||
$txt | ||
$border | ||
$ln | ||
$align | ||
$fill | ||
$link | ||
$stretch |
- See
- \include/tcpdf/TCPDF#Cell()
Header(
)
:
void
[OVERRIDE] This method override the regular Header() method to enable the custom image directory in addition to the OOB image directory.
Inherited from: \Sugarpdf::Header()This method is used to render the page header. It is automatically called by AddPage().
- Access
- public
- See
- \include/tcpdf/TCPDF#Header()
Ln1(
)
:
void
This Ln1() method will always print a line break of one line height.
Inherited from: \Sugarpdf::Ln1()The regular Ln() method print a line break which has the height of the last printed cell.
Output(
$name
=
'doc.pdf', $dest
=
'I'
)
:
void
Disable zlib output compression if we are downloading the PDF.
Inherited from: \Sugarpdf::Output()Name | Type | Description |
---|---|---|
$name | ||
$dest |
- See
- \TCPDF::Output()
SetFont(
string $family, string $style
=
'', float $size
=
0, string $fontfile
=
''
)
:
void
[OVERRIDE] SetFont method in TCPDF Library This method override the regular SetFont() method to enable the custom font directory in addition to the OOB font directory.
Inherited from: \Sugarpdf::SetFont()Name | Type | Description |
---|---|---|
$family | string | Family font. It can be either a name defined by AddFont() or one of the standard Type1 families (case insensitive):
It is also possible to pass an empty string. In that case, the current family is retained. |
$style | string | Font style. Possible values are (case insensitive):
or any combination. The default value is regular. Bold and italic styles do not apply to Symbol and ZapfDingbats basic fonts or other fonts when not defined. |
$size | float | 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 |
$fontfile | string | The font definition file. By default, the name is built from the family and style, in lower case with no spaces. |
- Access
- public
- See
- \include/tcpdf/TCPDF#SetFont()
__construct(
$bean
=
null, $sugarpdf_object_map
=
array(), $orientation
=
PDF_PAGE_ORIENTATION, $unit
=
PDF_UNIT, $format
=
PDF_PAGE_FORMAT, $unicode
=
true, $encoding
=
'UTF-8', $diskcache
=
false
)
:
void
Name | Type | Description |
---|---|---|
$bean | ||
$sugarpdf_object_map | ||
$orientation | ||
$unit | ||
$format | ||
$unicode | ||
$encoding | ||
$diskcache |
displayErrors(
)
:
void
This method will display the errors on the page.
Inherited from: \Sugarpdf::displayErrors()getLineHeightFromArray(
\$line $line, \$width $width
)
:
\The
Return the heigth of a line depending of the width, the font and the content
Inherited from: \Sugarpdf::getLineHeightFromArray()Name | Type | Description |
---|---|---|
$line | \$line | Array containing the data of all the cells of the line |
$width | \$width | Array containing the width of all the cells of the line |
Type | Description |
---|---|
\The | heigth of the line |
getNumLines(
string $txt, float $w
=
0
)
:
int
This is method is fix for a better handling of the count. This method now handle the line break between words.
Inherited from: \Sugarpdf::getNumLines()This method returns the estimated number of lines required to print the text.
Name | Type | Description |
---|---|---|
$txt | string | text to print |
$w | float | width of cell. If 0, they extend up to the right margin of the page. |
Type | Description |
---|---|
int | Return the estimated number of lines. |
- Access
- public
- OVERRIDE
- Since
- 4.5.011
initOptionsForWriteCellTable(
\$options $options, \$item $item
)
:
\$options
Private method for writeCellTable which format and initialize the options array.
Inherited from: \Sugarpdf::initOptionsForWriteCellTable()Name | Type | Description |
---|---|---|
$options | \$options | array |
$item | \$item | array |
Type | Description |
---|---|
\$options | array |
preDisplay(
)
:
void
[OVERRIDE] - This method is meant to overidden in a subclass. The purpose of this method is to allow a view to do some preprocessing before the display method is called. This becomes useful when you have a view defined at the application level and then within a module have a sub-view that extends from this application level view. The application level view can do the setup in preDisplay() that is common to itself and any subviews and then the subview can just override display(). If it so desires, can also override preDisplay().
process(
)
:
void
This method will be called from the controller and is not meant to be overridden.
Inherited from: \Sugarpdf::process()wrap(
$tag, $value, $options
)
:
\the
return the HTML code of the value wrap with the tag $tag. This method handle options (general and specific)
Inherited from: \Sugarpdf::wrap()Name | Type | Description |
---|---|---|
$tag | ||
$value | ||
$options |
Type | Description |
---|---|
\the | HTML wrapped code |
writeCellTable(
\$item $item, \$options $options
=
NULL
)
:
void
This method allow printing a table using the MultiCell method with a formatted options array in parameter Options : header options override the regular options for the header's cells - $options['header'] cell options override the regular options for the specific cell - Array[line number (0 to x)][cell header]['options']
Inherited from: \Sugarpdf::writeCellTable()Name | Type | Description |
---|---|---|
$item | \$item | Array[line number (0 to x)][cell header] = Cell content OR Array[line number (0 to x)][cell header]['value'] = Cell content AND Array[line number (0 to x)][cell header]['options'] = Array[cell properties] = values |
$options | \$options | Array which can contain : width (array 'column name'=>'width value + % OR nothing'), isheader (bool), header (array), fill (string: HTML color), ishtml (bool) default: false, border (0: no border (defaul), 1: frame or all of the following characters: L ,T ,R ,B), align (L: left align, C: center, R: right align, J: justification), stretch (array 'column name'=>stretch type) |
- See
- \MultiCell()
writeHTMLTable(
\$item $item, \$returnHtml $returnHtml
=
false, \$options $options
=
NULL
)
:
\the
This method allow printing a table using the writeHTML method with a formatted array in parameter This method can also return the table as HTML code
Inherited from: \Sugarpdf::writeHTMLTable()Name | Type | Description |
---|---|---|
$item | \$item | Array[line number (0 to x)][cell header] = Cell content OR Array[line number (0 to x)][cell header]['value'] = Cell content AND Array[line number (0 to x)][cell header]['options'] = Array[cell properties] = values |
$returnHtml | \$returnHtml | (bool) Return the table as HTML code instead of printing the HTML table |
$options | \$options | Array which can contain : table (array of "HTML proprty"=>"value"),td (array of "HTML proprty"=>"value"), tr (array of "HTML proprty"=>"value"), isheader(bool), header (array of "HTML proprty"=>"value"), width (array 'column name'=>'width value + unit OR nothing') |
Type | Description |
---|---|
\the | HTML code if $returnHtml set to true |