55require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/lib/format_cards.lib.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/class/commondocgenerator.class.php';
79 protected $_Avery_Name =
'';
81 protected $_Avery_Code =
'';
83 protected $_Margin_Left = 0;
85 protected $_Margin_Top = 0;
87 protected $_X_Space = 0;
89 protected $_Y_Space = 0;
91 protected $_X_Number = 0;
93 protected $_Y_Number = 0;
95 protected $_Width = 0;
97 protected $_Height = 0;
99 protected $_Char_Size = 10;
101 protected $_Line_Height = 10;
103 protected $_Metric =
'mm';
105 protected $_Metric_Doc =
'mm';
106 protected $_COUNTX = 1;
107 protected $_COUNTY = 1;
108 protected $_First = 1;
117 public $_Avery_Labels;
141 abstract public function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir =
'', $filename =
'');
152 abstract public function addSticker(&$pdf, $outputlangs, $param);
167 $this->_Char_Size = $pt;
169 $pdf->SetFont(
'',
'', $pt);
187 protected function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15)
190 $pdf->SetLineWidth($epaisseur);
191 $length = abs($x1 - $x2);
192 $hauteur = abs($y1 - $y2);
193 if ($length > $hauteur) {
194 $Pointilles = ($length / $nbPointilles) / 2;
196 $Pointilles = ($hauteur / $nbPointilles) / 2;
198 for ($i = $x1; $i <= $x2; $i += $Pointilles + $Pointilles) {
199 for ($j = $i; $j <= ($i + $Pointilles); $j++) {
200 if ($j <= ($x2 - 1)) {
202 $pdf->Line($j, $y1, $j + 1, $y1);
204 $pdf->Line($j, $y2, $j + 1, $y2);
208 for ($i = $y1; $i <= $y2; $i += $Pointilles + $Pointilles) {
209 for ($j = $i; $j <= ($i + $Pointilles); $j++) {
210 if ($j <= ($y2 - 1)) {
212 $pdf->Line($x1, $j, $x1, $j + 1);
214 $pdf->Line($x2, $j, $x2, $j + 1);
236 protected function _Croix(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $taille = 4)
239 $pdf->SetDrawColor(192, 192, 192);
241 $pdf->SetLineWidth($epaisseur);
244 $pdf->Line($x1, $y1 - $lg, $x1, $y1 + $lg);
245 $pdf->Line($x1 - $lg, $y1, $x1 + $lg, $y1);
247 $pdf->Line($x1, $y2 - $lg, $x1, $y2 + $lg);
248 $pdf->Line($x1 - $lg, $y2, $x1 + $lg, $y2);
250 $pdf->Line($x2, $y1 - $lg, $x2, $y1 + $lg);
251 $pdf->Line($x2 - $lg, $y1, $x2 + $lg, $y1);
253 $pdf->Line($x2, $y2 - $lg, $x2, $y2 + $lg);
254 $pdf->Line($x2 - $lg, $y2, $x2 + $lg, $y2);
256 $pdf->SetDrawColor(0, 0, 0);
275 return $value * $tab[$dest] / $tab[$src];
293 $_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);
294 if (in_array($pt, array_keys($_Table_Hauteur_Chars))) {
295 return $_Table_Hauteur_Chars[$pt];
313 $this->_Metric = $format[
'metric'];
314 $this->_Avery_Name = $format[
'name'];
315 $this->_Avery_Code = empty($format[
'code']) ?
'' : $format[
'code'];
316 $this->_Margin_Left = $this->
convertMetric($format[
'marginLeft'], $this->_Metric, $this->_Metric_Doc);
317 $this->_Margin_Top = $this->
convertMetric($format[
'marginTop'], $this->_Metric, $this->_Metric_Doc);
318 $this->_X_Space = $this->
convertMetric($format[
'SpaceX'], $this->_Metric, $this->_Metric_Doc);
319 $this->_Y_Space = $this->
convertMetric($format[
'SpaceY'], $this->_Metric, $this->_Metric_Doc);
320 $this->_X_Number = $format[
'NX'];
321 $this->_Y_Number = $format[
'NY'];
322 $this->_Width = $this->
convertMetric($format[
'width'], $this->_Metric, $this->_Metric_Doc);
323 $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.
_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 realisant une croix aux 4 coins des cartes
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)