diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index e3bb0cbe..2c1a5fae 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -157,8 +157,10 @@ class Labels extends CI_Controller { try { if ($label) { + $ptype=$this->labels_model->getPaperType($label->paper_type); // fetch papersize out of paper-table + var_dump($ptype); $pdf = new PDF_Label(array( - 'paper-size' => $label->paper_type, + 'paper-size' => 'custom', // $label->paper_type, // The only Type left is "custom" because A4 and so on are also defined at paper_types 'metric' => $label->metric, 'marginLeft' => $label->marginleft, 'marginTop' => $label->margintop, @@ -168,7 +170,9 @@ class Labels extends CI_Controller { 'SpaceY' => $label->spacey, 'width' => $label->width, 'height' => $label->height, - 'font-size' => $label->font_size + 'font-size' => $label->font_size, + 'pgX' => $ptype->width, + 'pgY' => $ptype->height )); } else { if ($jscall) { diff --git a/application/models/Labels_model.php b/application/models/Labels_model.php index 4e57cd0c..18835692 100644 --- a/application/models/Labels_model.php +++ b/application/models/Labels_model.php @@ -117,6 +117,14 @@ class Labels_model extends CI_Model { return $query->row(); } + function getPaperType($ptype) { + $this->db->where('user_id', $this->session->userdata('user_id')); + $this->db->where('id',$ptype); + $query = $this->db->get('paper_types'); + + return $query->row(); + } + function saveDefaultLabel($id) { $sql = 'update label_types set useforprint = 0 where user_id = ' . $this->session->userdata('user_id'); $this->db->query($sql); diff --git a/src/Label/PDF_Label.php b/src/Label/PDF_Label.php index 3d44ac7c..e4083056 100644 --- a/src/Label/PDF_Label.php +++ b/src/Label/PDF_Label.php @@ -69,25 +69,26 @@ class PDF_Label extends tfpdf { ); // Constructor - function __construct($format, $unit='mm', $posX=1, $posY=1) { - if (is_array($format)) { - // Custom format - $Tformat = $format; - } else { - // Built-in format - if (!isset($this->_Avery_Labels[$format])) - $this->Error('Unknown label format: '.$format); - $Tformat = $this->_Avery_Labels[$format]; - } + function __construct($format, $unit='mm', $posX=1, $posY=1, $pgX=0,$pgY=0) { + if (is_array($format)) { + // Custom format + var_dump("X".$pgX); + $Tformat = $format; + } else { + // Built-in format + if (!isset($this->_Avery_Labels[$format])) + $this->Error('Unknown label format: '.$format); + $Tformat = $this->_Avery_Labels[$format]; + } - parent::__construct('P', $unit, $Tformat['paper-size']); - $this->_Metric_Doc = $unit; - $this->_Set_Format($Tformat); - $this->SetFont('Arial'); - $this->SetMargins(0,0); - $this->SetAutoPageBreak(false); - $this->_COUNTX = $posX-2; - $this->_COUNTY = $posY-1; + parent::__construct('P', $unit, $Tformat['paper-size'],$Tformat['pgX'],$Tformat['pgY']); + $this->_Metric_Doc = $unit; + $this->_Set_Format($Tformat); + $this->SetFont('Arial'); + $this->SetMargins(0,0); + $this->SetAutoPageBreak(false); + $this->_COUNTX = $posX-2; + $this->_COUNTY = $posY-1; } function _Set_Format($format) { diff --git a/src/Label/tfpdf.php b/src/Label/tfpdf.php index a6d6825d..038066b8 100644 --- a/src/Label/tfpdf.php +++ b/src/Label/tfpdf.php @@ -74,7 +74,7 @@ protected $PDFVersion; // PDF version number * Public methods * *******************************************************************************/ -function __construct($orientation='P', $unit='mm', $size='A4') +function __construct($orientation='P', $unit='mm', $size='A4',$pgX = 0,$pgY =0) { // Some checks $this->_dochecks(); @@ -131,6 +131,9 @@ function __construct($orientation='P', $unit='mm', $size='A4') // Page sizes $this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28), 'letter'=>array(612,792), 'legal'=>array(612,1008)); + if ($size == 'custom') { + $size=array($pgX,$pgY); + } $size = $this->_getpagesize($size); $this->DefPageSize = $size; $this->CurPageSize = $size;