noalyss Version-9
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')
 
 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)
 
 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
 

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

Private 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)
private

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

264 {
265 $size=count($this->cells);
266 $this->cells[$size]=$Ce;
267
268 }
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 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 )
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 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().

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

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

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

284 {
285 $this->print_row();
286 if ( $this->bigger==0)
287 parent::Ln($p_step);
288 else
289 parent::Ln($this->bigger);
290 $this->bigger=0;
291 }
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 274 of file pdf_core.class.php.

275 {
276 $this->add_cell(new Cellule($w,$h,$txt,$border,0,$align,$fill,'','M'));
277
278 }
foreach($array as $idx=> $m) $w
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.
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 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
247 parent::Cell( $a->width,
248 $a->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, $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 269 of file pdf_core.class.php.

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

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

◆ $bigger

PDF_Core::$bigger
private

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

◆ $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: