noalyss Version-9
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
PDF_Core Class Reference

API for creating PDF, unicode, based on tfpdf. More...

+ Inheritance diagram for PDF_Core:
+ Collaboration diagram for PDF_Core:

Public Member Functions

 __construct ( $orientation='P', $unit='mm', $format='A4')
 
 get_margin_bottom ()
 
 get_margin_left ()
 
 get_margin_right ()
 
 get_margin_top ()
 
 get_orientation ()
 
 get_page_size ()
 
 get_unit ()
 
 is_fill ($p_step)
 If the step is even then return 1 and set the backgroup color to blue , otherwise returns 0, and set the background color to white It is use to compute alternated colored row , it the parameter fill in write_cell and cell. More...
 
 line_new ($p_step=null)
 Print all the cell stored and call Ln (new line) More...
 
 LongLine ($w, $h, $txt, $border=0, $align='', $fill=false)
 
 write_cell ($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
 

Protected Member Functions

 print_row ()
 print the current array of cell and reset it , if different colors are set on the same row you have to print it before changing More...
 

Private Member Functions

 add_cell (Cellule $Ce)
 
 check_page_add ()
 Check if a page must be added due a MultiCell. More...
 
 count_nb_row ($p_text, $p_colSize)
 Count the number of rows a p_text will take for a multicell. More...
 

Private Attributes

 $cells =array()
 

Detailed Description

API for creating PDF, unicode, based on tfpdf.

See also
TFPDF

Definition at line 62 of file pdf_core.class.php.

Constructor & Destructor Documentation

◆ __construct()

PDF_Core::__construct (   $orientation = 'P',
  $unit = 'mm',
  $format = 'A4' 
)

Definition at line 69 of file pdf_core.class.php.

70 {
71 $this->bigger=0;
72
73 parent::__construct($orientation, $unit, $format);
74 $this->AddFont('DejaVu','','DejaVuSans.ttf',true);
75 $this->AddFont('DejaVu','I','DejaVuSans-Oblique.ttf',true);
76 $this->AddFont('DejaVu','B','DejaVuSans-Bold.ttf',true);
77 $this->AddFont('DejaVu','BI','DejaVuSans-BoldOblique.ttf',true);
78 $this->AddFont('DejaVuCond','','DejaVuSansCondensed.ttf',true);
79 $this->AddFont('DejaVuCond','B','DejaVuSansCondensed-Bold.ttf',true);
80 $this->AddFont('DejaVuCond','I','DejaVuSansCondensed-Oblique.ttf',true);
81 $this->AddFont('DejaVuCond','BI','DejaVuSansCondensed-BoldOblique.ttf',true);
82
83
84
85 $this->cells=array();
86 }

Member Function Documentation

◆ add_cell()

PDF_Core::add_cell ( Cellule  $Ce)
private

Definition at line 262 of file pdf_core.class.php.

263 {
264 $size=count($this->cells);
265 $this->cells[$size]=$Ce;
266
267 }
if(count($array)==0) $size

References $size.

Referenced by LongLine(), and write_cell().

◆ check_page_add()

PDF_Core::check_page_add ( )
private

Check if a page must be added due a MultiCell.

Returns
boolean

On doit calculer si le texte dépasse la texte et compter le nombre de lignes que le texte prendrait. Ensuite il faut faire un saut de page (renvoit true) si dépasse

Definition at line 155 of file pdf_core.class.php.

156 {
157 // break on page
158 $size=count($this->cells);
159 for ($i=0;$i < $size ; $i++)
160 {
161 if ($this->cells[$i]->type == 'M' )
162 {
163 /**
164 * On doit calculer si le texte dépasse la texte et compter le
165 * nombre de lignes que le texte prendrait. Ensuite il faut
166 * faire un saut de page (renvoit true) si dépasse
167 */
168
169 $sizetext=$this->GetStringWidth($this->cells[$i]->text);
170
171 // if text bigger than column width then check
172
173 $y=$this->GetY();
174 $nb_row=$this->count_nb_row($this->cells[$i]->text, $this->cells[$i]->width);
175 $height=$this->cells[$i]->height*$nb_row;
176
177 // If the text is bigger than a sheet of paper then return false
178 if ($height >= $this->h) return false;
179
180 if ( $y + $height > ($this->h - $this->bMargin -7 ))
181 return true;
182
183 }
184 }
185 return false;
186 }
h( $row[ 'oa_description'])
$input_from type
Definition: balance.inc.php:65
count_nb_row($p_text, $p_colSize)
Count the number of rows a p_text will take for a multicell.
$desc width

References $i, $nb_row, $size, count_nb_row(), h, type, and width.

Referenced by print_row().

+ Here is the call graph for this function:

◆ count_nb_row()

PDF_Core::count_nb_row (   $p_text,
  $p_colSize 
)
private

Count the number of rows a p_text will take for a multicell.

Parameters
$p_textString
$p_colSizesize of the column in User Unit

Definition at line 121 of file pdf_core.class.php.

122 {
123 // If colSize is bigger than the size of the string then it takes 1 line
124 if ( $this->GetStringWidth($p_text) <= $p_colSize) return 1;
125 $nRow=0;
126 $aWords=explode(' ',$p_text);
127 $nb_words=count($aWords);
128 $string="";
129
130 for ($i=0;$i < $nb_words;$i++){
131 // Concatenate String with current word + a space
132 $string.=$aWords[$i];
133
134 // if there is a word after add a space
135 if ( $i+1 < $nb_words) $string.=" ";
136
137 // Compute new size and compare to the colSize
138 if ( $this->GetStringWidth($string) >= $p_colSize) {
139 // If the size of the string if bigger than we add a row, the current
140 // word is the first word of the next line
141 $nRow++;
142 $string=$aWords[$i];
143 }
144 }
145 $nRow++;
146 return $nRow;
147
148
149
150 }

References $i, and $string.

Referenced by check_page_add().

◆ get_margin_bottom()

PDF_Core::get_margin_bottom ( )

Definition at line 91 of file pdf_core.class.php.

92 {
93 return $this->bMargin;
94
95 }

◆ get_margin_left()

PDF_Core::get_margin_left ( )

Definition at line 87 of file pdf_core.class.php.

88 {
89 return $this->lMargin;
90 }

◆ get_margin_right()

PDF_Core::get_margin_right ( )

Definition at line 100 of file pdf_core.class.php.

101 {
102 return $this->rMargin;
103 }

◆ get_margin_top()

PDF_Core::get_margin_top ( )

Definition at line 96 of file pdf_core.class.php.

97 {
98 return $this->tMargin;
99 }

◆ get_orientation()

PDF_Core::get_orientation ( )

Definition at line 104 of file pdf_core.class.php.

105 {
106 return $this->DefOrientation;
107 }

◆ get_page_size()

PDF_Core::get_page_size ( )

Definition at line 112 of file pdf_core.class.php.

113 {
114 return $this->DefPageSize;
115 }

◆ get_unit()

PDF_Core::get_unit ( )

Definition at line 108 of file pdf_core.class.php.

109 {
110 return $this->k;
111 }

◆ is_fill()

PDF_Core::is_fill (   $p_step)

If the step is even then return 1 and set the backgroup color to blue , otherwise returns 0, and set the background color to white It is use to compute alternated colored row , it the parameter fill in write_cell and cell.

See also
PDF:write_cell
TPDF:cell

Definition at line 300 of file pdf_core.class.php.

301 {
302 if ($p_step % 2 == 0) {
303 $this->SetFillColor(239, 239, 255);
304 $fill = 1;
305 } else {
306 $this->SetFillColor(255, 255, 255);
307 $fill = 0;
308 }
309 return $fill;
310 }

References $p_step.

◆ line_new()

PDF_Core::line_new (   $p_step = null)

Print all the cell stored and call Ln (new line)

Parameters
int$p_step

Definition at line 283 of file pdf_core.class.php.

283 {
284 $this->print_row();
285 if ( $this->bigger==0)
286 parent::Ln($p_step);
287 else
288 parent::Ln($this->bigger);
289 $this->bigger=0;
290 }
print_row()
print the current array of cell and reset it , if different colors are set on the same row you have t...

References $p_step, and print_row().

Referenced by Card_PDF\export(), Print_Ledger_Detail\export(), Print_Ledger_Detail_Item\export(), Print_Ledger_Financial\export(), Print_Ledger_Misc\export(), Print_Ledger_Simple\export(), Print_Ledger_Simple_Without_Vat\export(), and Print_Ledger_Detail_Item\Header().

+ Here is the call graph for this function:

◆ LongLine()

PDF_Core::LongLine (   $w,
  $h,
  $txt,
  $border = 0,
  $align = '',
  $fill = false 
)

Definition at line 273 of file pdf_core.class.php.

274 {
275 $this->add_cell(new Cellule($w,$h,$txt,$border,0,$align,$fill,'','M'));
276
277 }
foreach($array as $idx=> $m) $w
A Cellule is a cell to print.
add_cell(Cellule $Ce)

References $align, $w, and add_cell().

Referenced by Print_Ledger_Detail\export(), Print_Ledger_Detail_Item\export(), Print_Ledger_Financial\export(), Print_Ledger_Misc\export(), Print_Ledger_Simple\export(), and Print_Ledger_Simple_Without_Vat\export().

+ Here is the call graph for this function:

◆ print_row()

PDF_Core::print_row ( )
protected

print the current array of cell and reset it , if different colors are set on the same row you have to print it before changing

// fill red , text white
$this->SetFillColor(255,0,0);
$this->SetTextColor(255,255,255);
$this->write_cell(15,5,"PRICE",0,0,'R',fill:true);
// print the cell without a linefeed
$this->print_row();
// text in black on green
$this->SetTextColor(0,0,0);
$this->SetFillColor(0,255,0);
$this->write_cell(15,5,nbm($other['price']),0,0,'R');
nbm($p_number, $p_dec=2)
format the number with a sep.
Definition: ac_common.php:137
write_cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
See also
TFPDF::SetTextColor()
TFPDF::SetFillColor()
TFPDF::SetFontSize()
Returns
void

Definition at line 212 of file pdf_core.class.php.

213 {
214 static $e=0;
215 $e++;
216 if ( $this->check_page_add() == true ) $this->AddPage ();
217 $this->bigger=0;
218 $size=count($this->cells);
219 $cell=$this->cells;
220 if ($size == 0 )return;
221 for ($i=0;$i < $size ; $i++)
222 {
223 $a=$cell[$i];
224 $a->text= noalyss_str_replace("\\", "", $a->text);
225 switch ($a->type)
226 {
227 case "M":
228 $x_m=$this->GetX();
229 $y_m=$this->GetY();
230 parent::MultiCell(
231 $a->width,
232 $a->height,
233 $a->text,
234 $a->border,
235 $a->align,
236 $a->fill
237 );
238 $x_m=$x_m+$a->width;
239 $tmp=$this->GetY()-$y_m;
240 if ( $tmp > $this->bigger) $this->bigger=$tmp;
241 $this->SetXY($x_m,$y_m);
242 break;
243
244 case "C":
245
246 parent::Cell( $a->width,
247 $a->height,
248 $a->text,
249 $a->border,
250 $a->new_line,
251 $a->align,
252 $a->fill,
253 $a->link);
254 break;
255
256 default:
257 break;
258 }
259 }
260 $this->cells=array();
261 }
noalyss_str_replace($search, $replace, $string)
Definition: ac_common.php:1553
check_page_add()
Check if a page must be added due a MultiCell.

References $a, $cells, $e, $i, $size, $tmp, check_page_add(), and noalyss_str_replace().

Referenced by line_new().

+ Here is the call graph for this function:

◆ write_cell()

PDF_Core::write_cell (   $w,
  $h = 0,
  $txt = '',
  $border = 0,
  $ln = 0,
  $align = '',
  $fill = false,
  $link = '' 
)

Definition at line 268 of file pdf_core.class.php.

269 {
270 $this->add_cell(new Cellule($w,$h,$txt,$border,$ln,$align,$fill,$link,'C'));
271
272 }

References $align, $w, and add_cell().

Referenced by Card_PDF\export(), Print_Ledger_Detail\export(), Print_Ledger_Detail_Item\export(), Print_Ledger_Financial\export(), Print_Ledger_Misc\export(), Print_Ledger_Simple\export(), Print_Ledger_Simple_Without_Vat\export(), and Print_Ledger_Detail_Item\Header().

+ Here is the call graph for this function:

Field Documentation

◆ $cells

PDF_Core::$cells =array()
private

Definition at line 67 of file pdf_core.class.php.

Referenced by print_row().


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