include/Sugarpdf/sugarpdf/sugarpdf.smarty.php

Show: inherited
Table of Contents

\SugarpdfSmarty

Package: SugarCRM

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

Constant  STRETCH_NONE = 0
inherited

Stretch options constants

Inherited from: \Sugarpdf::STRETCH_NONE
Inherited_from
\Sugarpdf::STRETCH_NONE  
Constant  STRETCH_SCALE = 1
inheritedInherited from: \Sugarpdf::STRETCH_SCALE
Inherited_from
\Sugarpdf::STRETCH_SCALE  
Constant  STRETCH_SCALE_FORCED = 2
inheritedInherited from: \Sugarpdf::STRETCH_SCALE_FORCED
Constant  STRETCH_SPACING = 3
inheritedInherited from: \Sugarpdf::STRETCH_SPACING
Inherited_from
\Sugarpdf::STRETCH_SPACING  
Constant  STRETCH_SPACING_FORCED = 4
inheritedInherited from: \Sugarpdf::STRETCH_SPACING_FORCED

Properties

Propertypublic  $aclAction= 'PDF_ACL_ACCESS'
inherited

Use for the ACL access.

Inherited from: \Sugarpdf::$$aclAction
Default valuePDF_ACL_ACCESSDetails
Type
n/a
Inherited_from
\Sugarpdf::$$aclAction  
Propertypublic  $action= ''''
inherited

The name of the current action.

Inherited from: \Sugarpdf::$$action
Default value''Details
Type
n/a
Inherited_from
\Sugarpdf::$$action  
Propertypublic  $bean= 'null'
inherited

Inherited from: \Sugarpdf::$$bean
Default valuenullDetails
Type
n/a
Inherited_from
\Sugarpdf::$$bean  
Propertypublic  $errors= 'array()'
inherited

Any errors that occured this can either be set by the view or the controller or the model

Inherited from: \Sugarpdf::$$errors
Default valuearray()Details
Type
n/a
Inherited_from
\Sugarpdf::$$errors  
Propertypublic  $fileName= 'PDF_FILENAME'
inherited

Use to set the filename of the output pdf file.

Inherited from: \Sugarpdf::$$fileName
Default valuePDF_FILENAMEDetails
Type
n/a
Inherited_from
\Sugarpdf::$$fileName  
Propertypublic  $module= ''''
inherited

The name of the current module.

Inherited from: \Sugarpdf::$$module
Default value''Details
Type
n/a
Inherited_from
\Sugarpdf::$$module  
Propertyprotected  $smartyAlign= '""'
Default value""Details
Type
n/a
Propertyprotected  $smartyCell= 'false'
Default valuefalseDetails
Type
n/a
Propertyprotected  $smartyFill= 'false'
Default valuefalseDetails
Type
n/a
Propertyprotected  $smartyLn= 'true'

These 5 variables are use for the writeHTML method.

Default valuetrueDetails
Type
n/a
See
\include/tcpdf/tcpdf.php  
Propertyprotected  $smartyReseth= 'false'
Default valuefalseDetails
Type
n/a
Propertyprotected\Sugar_Smarty  $ss= ''

The Sugar_Smarty object

Details
Type
\Sugar_Smarty
Propertypublic  $sugarpdf_object_map= 'array()'
inherited

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_map
Default valuearray()Details
Type
n/a
Inherited_from
\Sugarpdf::$$sugarpdf_object_map  
PropertyprotectedString  $templateLocation= '""'

Default value""Details
Type
String

Methods

methodpublicCell(  $w,  $h = 0,  $txt = '',  $border = 0,  $ln = 0,  $align = '',  $fill = 0,  $link = '',  $stretch = 0 ) : void
inherited

[OVERRIDE] Cell method in tcpdf library.

Inherited from: \Sugarpdf::Cell()

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).

Parameters
Name Type Description
$w
$h
$txt
$border
$ln
$align
$fill
$link
$stretch
Details
See
\include/tcpdf/TCPDF#Cell()  
methodpublicHeader( ) : void
inherited

[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().

Details
Access
public  
See
\include/tcpdf/TCPDF#Header()  
methodpublicInfo( ) : void
inherited

Inherited from: \Sugarpdf::Info()
methodpublicLn1( ) : void
inherited

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.

methodpublicOutput(  $name = 'doc.pdf',  $dest = 'I' ) : void
inherited

Disable zlib output compression if we are downloading the PDF.

Inherited from: \Sugarpdf::Output()
Parameters
Name Type Description
$name
$dest
Details
See
\TCPDF::Output()  
methodpublicSetFont( string $family, string $style = '', float $size = 0, string $fontfile = '' ) : void
inherited

[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()
Parameters
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):

  • times (Times-Roman)
  • timesb (Times-Bold)
  • timesi (Times-Italic)
  • timesbi (Times-BoldItalic)
  • helvetica (Helvetica)
  • helveticab (Helvetica-Bold)
  • helveticai (Helvetica-Oblique)
  • helveticabi (Helvetica-BoldOblique)
  • courier (Courier)
  • courierb (Courier-Bold)
  • courieri (Courier-Oblique)
  • courierbi (Courier-BoldOblique)
  • symbol (Symbol)
  • zapfdingbats (ZapfDingbats)

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):

  • empty string: regular
  • B: bold
  • I: italic
  • U: underline
  • D: line trough

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.

Details
Access
public  
See
\include/tcpdf/TCPDF#SetFont()  
methodpublic__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
inherited

Constructor which will peform the setup.

Inherited from: \Sugarpdf::__construct()
Parameters
Name Type Description
$bean
$sugarpdf_object_map
$orientation
$unit
$format
$unicode
$encoding
$diskcache
methodprivate_initSmartyInstance( ) : void

Init the Sugar_Smarty object.

methodpublicdisplay( ) : void

[OVERRIDE] - This method is meant to overidden in a subclass.

methodpublicdisplayErrors( ) : void
inherited

This method will display the errors on the page.

Inherited from: \Sugarpdf::displayErrors()
methodprivategetLineHeightFromArray( \$line $line, \$width $width ) : \The
inherited

Return the heigth of a line depending of the width, the font and the content

Inherited from: \Sugarpdf::getLineHeightFromArray()
Parameters
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

Returns
Type Description
\The heigth of the line
methodpublicgetNumLines( string $txt, float $w = 0 ) : int
inherited

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.

Parameters
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.

Returns
Type Description
int Return the estimated number of lines.
Details
Access
public  
OVERRIDE
 
Since
4.5.011  
methodprivateinitOptionsForWriteCellTable( \$options $options, \$item $item ) : \$options
inherited

Private method for writeCellTable which format and initialize the options array.

Inherited from: \Sugarpdf::initOptionsForWriteCellTable()
Parameters
Name Type Description
$options \$options

array

$item \$item

array

Returns
Type Description
\$options array
methodpublicpreDisplay( ) : 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().

methodpublicprocess( ) : void
inherited

This method will be called from the controller and is not meant to be overridden.

Inherited from: \Sugarpdf::process()
methodprivatewrap(  $tag,  $value,  $options ) : \the
inherited

return the HTML code of the value wrap with the tag $tag. This method handle options (general and specific)

Inherited from: \Sugarpdf::wrap()
Parameters
Name Type Description
$tag
$value
$options
Returns
Type Description
\the HTML wrapped code
methodpublicwriteCellTable( \$item $item, \$options $options = NULL ) : void
inherited

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()
Parameters
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)

Details
See
\MultiCell()  
methodpublicwriteHTMLTable( \$item $item, \$returnHtml $returnHtml = false, \$options $options = NULL ) : \the
inherited

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()
Parameters
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')

Returns
Type Description
\the HTML code if $returnHtml set to true
Documentation was generated by DocBlox 0.18.1.