noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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')
 
 fill_row ($enable)
 set color for row ,
 
 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.
 
 line_new ($p_step=null)
 Print all the cell stored and call Ln (new line)
 
 LongLine ($w, $h, $txt, $border=0, $align='', $fill=false)
 add a cell with automatic return to the line if the text is too long, deprecated , it calls only PDFCore::write_cell_
 
 write_cell ($width, $height=0, $txt='', $border=0, $interline=0, $align='', $fill=false, $link='')
 add a cell the text is not cut and don't return to this line if too large
 
 write_multi ($width, $interline, $txt, $border=0, $align='', $fill=false)
 add a cell with automatic return to the line if the text is too long
 

Protected Member Functions

 add_cell (Cellule $Ce)
 
 check_page_add ()
 Check if a page must be added due a MultiCell.
 
 count_nb_row ($p_text, $p_colSize)
 Count the number of rows a p_text will take for a multicell.
 
 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
 

Protected Attributes

 $bigger
 
 $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 70 of file pdf_core.class.php.

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

Member Function Documentation

◆ add_cell()

PDF_Core::add_cell ( Cellule $Ce)
protected

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

264 {
265 $size=count($this->cells);
266 $this->cells[$size]=$Ce;
267
268 }
if(in_array( $type, array( 'CHA', 'ACT', 'PASINV', 'PROINV')) &&$tot_deb< $tot_cred) if(in_array($type, array('PRO', 'PAS', 'ACTINV', 'CHAINV')) && $tot_deb > $tot_cred) $size

References $size.

Referenced by write_cell(), and write_multi().

◆ check_page_add()

PDF_Core::check_page_add ( )
protected

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 156 of file pdf_core.class.php.

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

References $height, $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 )
protected

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 122 of file pdf_core.class.php.

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

References $i, and $string.

Referenced by check_page_add().

◆ fill_row()

PDF_Core::fill_row ( $enable)

set color for row ,

Parameters
$enable(int)set color 0 or disable 1
Returns
0 or 1

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

359 {
360 return $this->is_fill($enable);
361 }
is_fill($p_step)
If the step is even then return 1 and set the backgroup color to blue , otherwise returns 0,...

References is_fill().

Referenced by Print_Ledger_Detail_Item\export().

+ Here is the call graph for this function:

◆ get_margin_bottom()

PDF_Core::get_margin_bottom ( )

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

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

◆ get_margin_left()

PDF_Core::get_margin_left ( )

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

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

◆ get_margin_right()

PDF_Core::get_margin_right ( )

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

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

◆ get_margin_top()

PDF_Core::get_margin_top ( )

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

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

◆ get_orientation()

PDF_Core::get_orientation ( )

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

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

◆ get_page_size()

PDF_Core::get_page_size ( )

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

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

◆ get_unit()

PDF_Core::get_unit ( )

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

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

◆ 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 342 of file pdf_core.class.php.

343 {
344 if ($p_step % 2 == 0) {
345 $this->SetFillColor(239, 239, 255);
346 $fill = 1;
347 } else {
348 $this->SetFillColor(255, 255, 255);
349 $fill = 0;
350 }
351 return $fill;
352 }

References $p_step.

Referenced by fill_row().

◆ 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 325 of file pdf_core.class.php.

325 {
326 $this->print_row();
327 if ( $this->bigger==0)
328 parent::Ln($p_step);
329 else
330 parent::Ln($this->bigger);
331 $this->bigger=0;
332 }
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(), Print_Ledger_Detail_Item\Header(), and Noalyss\Invoice_PDF\header().

+ Here is the call graph for this function:

◆ LongLine()

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

add a cell with automatic return to the line if the text is too long, deprecated , it calls only PDFCore::write_cell_

See also
PDF_Core\write_multi()
Parameters
$wwidth (in PDF unit )
$hinterline (in pt)
$txttext to display
$borderborder valid values are 1 : border ,0 : no-border, T : top,B : bottom,L : left,R : right
$aligntext align valid values are L : left,R : right
$fillcolor true or false
Returns
void
Deprecated

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

316 {
317 $this->write_multi($w,$h,$txt,$border,$align,$fill);
318
319 }
foreach($array as $idx=> $m) $w
write_multi($width, $interline, $txt, $border=0, $align='', $fill=false)
add a cell with automatic return to the line if the text is too long

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

+ 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.
write_cell($width, $height=0, $txt='', $border=0, $interline=0, $align='', $fill=false, $link='')
add a cell the text is not cut and don't return to this line if too large
See also
TFPDF::SetTextColor()
TFPDF::SetFillColor()
TFPDF::SetFontSize()
Returns
void

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

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

References $a, $bigger, $cells, $e, $height, $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 ( $width,
$height = 0,
$txt = '',
$border = 0,
$interline = 0,
$align = '',
$fill = false,
$link = '' )

add a cell the text is not cut and don't return to this line if too large

Parameters
$widthwidth (in PDF unit )
$heightheight (in PDF unit )
$txttext to print (unicode)
$borderborder valid values are 1 : border ,0 : no-border, T : top,B : bottom,L : left,R : right
$interline(unit pt ) space between lines
$aligntext alignment valid values are L : left,R : right
$fillcolor true or false
$linkurl
Returns
void

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

282 {
283 $this->add_cell(new Cellule($width,$height,$txt,$border,$interline,$align,$fill,$link,'C'));
284
285 }
add_cell(Cellule $Ce)

References $align, $height, $width, 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:

◆ write_multi()

PDF_Core::write_multi ( $width,
$interline,
$txt,
$border = 0,
$align = '',
$fill = false )

add a cell with automatic return to the line if the text is too long

Parameters
$widthwidth (in PDF unit )
$interlineinterline (unit pt)
$txttext to print (unicode)
$borderborder valid values are 1 : border ,0 : no-border, T : top,B : bottom,L : left,R : right
$aligntext alignment valid values are L : left,R : right
$fillcolor true or false
Returns
void

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

297 {
298 $this->add_cell(new Cellule($width,$interline,$txt,$border,0,$align,$fill,'','M'));
299
300 }

References $align, $width, 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(), Print_Ledger_Simple_Without_Vat\export(), Noalyss\Invoice_PDF\header(), and LongLine().

+ Here is the call graph for this function:

Field Documentation

◆ $bigger

PDF_Core::$bigger
protected

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

Referenced by print_row().

◆ $cells

PDF_Core::$cells =array()
protected

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: