.

PDFMaker Class Reference

List of all members.

Public Member Functions

  __construct ($text, $filename, $template="")
  closeTag ($tag)
  create ($top=10, $left=10, $bottom=20)
  Creates the PDF and stores it under given filename.
  Footer ()
  openTag ($tag, &$arrAttributes)
  setStyle ($tag, $enable)
  writeFormatted ($lineHeight, $text)

Detailed Description

Definition at line 16 of file pdfmaker.cls.php.


Constructor & Destructor Documentation

PDFMaker::__construct ( text,
filename,
template = ""  
)

Definition at line 27 of file pdfmaker.cls.php.

00027                                                                       {
00028                 $this->text = $text;
00029                 $this->filename = $filename;
00030                 $this->template = $template;
00031                 if (!empty($this->template)) {
00032                         $this->template_pagecount = $this->setSourceFile($this->template);
00033                 }
00034                                 
00035                 FPDI::FPDI("P", "mm", "A4");
00036         }

Member Function Documentation

PDFMaker::closeTag ( tag  ) 

Definition at line 149 of file pdfmaker.cls.php.

00149                                 {
00150                 switch ($tag) {
00151                         case "B":
00152                         case "I":
00153                         case "U":
00154                                 $this->setStyle($tag, 0);
00155                                 break;
00156                         case "CELL":
00157                                 $this->cell = false;
00158                                 $this->skipFirstLF = true;
00159                                 break;
00160                 }
00161         }
PDFMaker::create ( top = 10,
left = 10,
bottom = 20  
)

Creates the PDF and stores it under given filename.

Parameters:
Integer  Text start top in mm
Integer  Text left in mm
Integer  Text bottom in mm
Returns:
Status

Definition at line 47 of file pdfmaker.cls.php.

00047                                                              {          
00048                 $this->AddPage();
00049                 $this->SetMargins($left, $top, $left);
00050                 $this->SetAutoPageBreak(true, $bottom);
00051                 $this->SetFont("helvetica", "", 9);
00052                 $this->SetXY($left, $top);
00053                 $this->writeFormatted(5, $this->text);
00054                 $this->Output($this->filename, "F");
00055         }
PDFMaker::Footer (  ) 

Definition at line 57 of file pdfmaker.cls.php.

00057                           {
00058                 $page_no = $this->PageNo();
00059                 $tpl_page = 0;
00060                 if ($page_no <= $this->template_pagecount) {
00061                         $tpl_page = $page_no;
00062                 }
00063                 else if ($this->template_pagecount > 0) {
00064                         $tpl_page = $this->template_pagecount;
00065                 }
00066                 if ($tpl_page) {
00067                         $tplidx = $this->ImportPage($tpl_page);
00068                         $this->useTemplate($tplidx);
00069                 }
00070         }
PDFMaker::openTag ( tag,
&$  arrAttributes  
)

Definition at line 133 of file pdfmaker.cls.php.

00133                                                 {
00134                 switch ($tag) {
00135                         case "B":
00136                         case "I":
00137                         case "U":
00138                                 $this->setStyle($tag, 1);
00139                                 break;
00140                         case "CELL":
00141                                 $this->cell = array();
00142                                 foreach($arrAttributes as $name => $value) {
00143                                         $this->cell[strtolower($name)] = strtoupper($value);
00144                                 }
00145                                 break;
00146                 }
00147         }
PDFMaker::setStyle ( tag,
enable  
)

Definition at line 163 of file pdfmaker.cls.php.

00163                                          {
00164                 //Modify style and select corresponding font
00165                 if (array_key_exists($tag, $this->style) == false) {
00166                         $this->style[$tag] = 0;
00167                 }
00168                         
00169                 $this->style[$tag] += ($enable ? 1 : -1);
00170                 $style='';
00171                 foreach($this->style as $s => $count) {
00172                         if($count > 0) {
00173                                 $style.=$s;
00174                         }
00175                 }
00176                 $this->SetFont('',$style);
00177         }
PDFMaker::writeFormatted ( lineHeight,
text  
)

Definition at line 72 of file pdfmaker.cls.php.

00072                                                     {
00073                 $arrText = preg_split('/<(.*)>/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
00074                 foreach($arrText as $index => $content) {
00075                         if($index % 2 == 0) {
00076                                 if ($this->cell !== false) {
00077                                         $arrCell = array(
00078                                                 "w" => 0,
00079                                                 "h" => 5,
00080                                                 "border" => 0,
00081                                                 "align" => "L",
00082                                                 "fill" => 0
00083                                         );
00084                                                  
00085                                         Arr::clean($arrCell, $this->cell);
00086                                         
00087                         //Text
00088                         $this->Cell(
00089                                 $arrCell["w"], 
00090                                 $arrCell["h"], 
00091                                 $content,
00092                               $arrCell["border"], 
00093                               0, 
00094                               $arrCell["align"], 
00095                               $arrCell["fill"]
00096                                         );
00097                                 }
00098                                 else {
00099                                         if (false && $this->skipFirstLF === true && strlen($content) > 0) {
00100                                                 if (strpos($content, "\r\n") === 0) {
00101                                                         $content = substr($content, 2);
00102                                                 }
00103                                                 else if(strpos($content, "\n") === 0) {
00104                                                         $content = substr($content, 1);
00105                                                 }
00106                                                 $this->skipFirstLF = false;
00107                                         }
00108                                                 
00109                                         $this->Write(5, $content);
00110                                 }
00111       }
00112       else {
00113                 //Tags
00114                                 if($content{0} == '/') {
00115                                         $this->closeTag(strtoupper(substr($content,1)));
00116                                 }
00117                                 else {
00118                                 //Extract attributes
00119                                         $arrAttrs = explode(' ', $content);
00120                                         $tag = strtoupper(array_shift($arrAttrs));
00121                                         $arrAttrValues = array();
00122                                         foreach($arrAttrs as $attrExpression) {
00123                                 if ( ereg('^([^=]*)=["\']?([^"\']*)["\']?$', $attrExpression, $temp)) {
00124                 $arrAttrValues[strtoupper($temp[1])] = $temp[2];
00125                                 }
00126                                         }
00127                         $this->openTag($tag, $arrAttrValues);
00128                 }
00129         }
00130     }
00131         }

The documentation for this class was generated from the following file: