56require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/class/commondocgenerator.class.php';
82 protected $_Avery_Name =
'';
87 protected $_Avery_Code =
'';
92 protected $_Margin_Left = 0;
97 protected $_Margin_Top = 0;
102 protected $_X_Space = 0;
107 protected $_Y_Space = 0;
112 protected $_X_Number = 0;
117 protected $_Y_Number = 0;
122 protected $_Width = 0;
127 protected $_Height = 0;
132 protected $_Char_Size = 10;
137 protected $_Line_Height = 10;
142 protected $_Metric =
'mm';
147 protected $_Metric_Doc =
'mm';
152 protected $_COUNTX = 1;
157 protected $_COUNTY = 1;
162 protected $_First = 1;
172 public $_Avery_Labels;
196 abstract public function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir =
'', $filename =
'');
207 abstract public function addSticker(&$pdf, $outputlangs, $param);
222 $this->_Char_Size = $pt;
224 $pdf->SetFont(
'',
'', $pt);
242 protected function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15)
245 $pdf->SetLineWidth($epaisseur);
246 $length = abs($x1 - $x2);
247 $hauteur = abs($y1 - $y2);
248 if ($length > $hauteur) {
249 $Pointilles = ($length / $nbPointilles) / 2;
251 $Pointilles = ($hauteur / $nbPointilles) / 2;
253 for ($i = $x1; $i <= $x2; $i += $Pointilles + $Pointilles) {
254 for ($j = $i; $j <= ($i + $Pointilles); $j++) {
255 if ($j <= ($x2 - 1)) {
257 $pdf->Line($j, $y1, $j + 1, $y1);
259 $pdf->Line($j, $y2, $j + 1, $y2);
263 for ($i = $y1; $i <= $y2; $i += $Pointilles + $Pointilles) {
264 for ($j = $i; $j <= ($i + $Pointilles); $j++) {
265 if ($j <= ($y2 - 1)) {
267 $pdf->Line($x1, $j, $x1, $j + 1);
269 $pdf->Line($x2, $j, $x2, $j + 1);
291 protected function _Croix(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $taille = 4)
294 $pdf->SetDrawColor(192, 192, 192);
296 $pdf->SetLineWidth($epaisseur);
299 $pdf->Line($x1, $y1 - $lg, $x1, $y1 + $lg);
300 $pdf->Line($x1 - $lg, $y1, $x1 + $lg, $y1);
302 $pdf->Line($x1, $y2 - $lg, $x1, $y2 + $lg);
303 $pdf->Line($x1 - $lg, $y2, $x1 + $lg, $y2);
305 $pdf->Line($x2, $y1 - $lg, $x2, $y1 + $lg);
306 $pdf->Line($x2 - $lg, $y1, $x2 + $lg, $y1);
308 $pdf->Line($x2, $y2 - $lg, $x2, $y2 + $lg);
309 $pdf->Line($x2 - $lg, $y2, $x2 + $lg, $y2);
311 $pdf->SetDrawColor(0, 0, 0);
330 return $value * $tab[$dest] / $tab[$src];
348 $_Table_Hauteur_Chars = array(6 => 2, 7 => 2.5, 8 => 3, 9 => 3.5, 10 => 4, 11 => 6, 12 => 7, 13 => 8, 14 => 9, 15 => 10);
349 if (in_array($pt, array_keys($_Table_Hauteur_Chars))) {
350 return $_Table_Hauteur_Chars[$pt];
368 $this->_Metric = $format[
'metric'];
369 $this->_Avery_Name = $format[
'name'];
370 $this->_Avery_Code = empty($format[
'code']) ?
'' : $format[
'code'];
371 $this->_Margin_Left = $this->
convertMetric($format[
'marginLeft'], $this->_Metric, $this->_Metric_Doc);
372 $this->_Margin_Top = $this->
convertMetric($format[
'marginTop'], $this->_Metric, $this->_Metric_Doc);
373 $this->_X_Space = $this->
convertMetric($format[
'SpaceX'], $this->_Metric, $this->_Metric_Doc);
374 $this->_Y_Space = $this->
convertMetric($format[
'SpaceY'], $this->_Metric, $this->_Metric_Doc);
375 $this->_X_Number = $format[
'NX'];
376 $this->_Y_Number = $format[
'NY'];
377 $this->_Width = $this->
convertMetric($format[
'width'], $this->_Metric, $this->_Metric_Doc);
378 $this->_Height = $this->
convertMetric($format[
'height'], $this->_Metric, $this->_Metric_Doc);
Parent class for documents (PDF, ODT, ...) generators.
Class to generate stick sheet with format Avery or other personalised format.
_Get_Height_Chars($pt)
protected Give the height for a char size given.
_Croix(&$pdf, $x1=0, $y1=0, $x2=210, $y2=297, $epaisseur=1, $taille=4)
protected Function making a cross at the 4 corners of the labels
Set_Char_Size(&$pdf, $pt)
Method to modify the size of characters This will also modify the space between lines.
convertMetric($value, $src, $dest)
Convert units (in to mm, mm to in) $src and $dest must be 'in' or 'mm'.
_Set_Format(&$pdf, $format)
protected Set format
write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir='', $filename='')
Function to build PDF on disk, then output on HTTP stream.
__construct($db)
Constructor.
_Pointille(&$pdf, $x1=0, $y1=0, $x2=210, $y2=297, $epaisseur=1, $nbPointilles=15)
protected Print dot line
addSticker(&$pdf, $outputlangs, $param)
Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)