----------------------------------------
authorDavid Doligalski <ddoligalski@backofficethinking.com>
Tue, 28 May 2013 21:24:20 +0000 (17:24 -0400)
committerDavid Doligalski <ddoligalski@backofficethinking.com>
Tue, 28 May 2013 21:24:20 +0000 (17:24 -0400)
* CRM-12710: Eliminate extra blank page from end of PDF labels (badges)
  http://issues.civicrm.org/jira/browse/CRM-12710

CRM/Utils/PDF/Label.php

index 20fef72064c4caaf7fab530474fc9184eda91d8e..19b873c9c82f47499d5d35a8b2e801d594329ee9 100644 (file)
@@ -213,6 +213,13 @@ class CRM_Utils_PDF_Label extends TCPDF {
    * function to Print a label
    */
   function AddPdfLabel($texte) {
+    if ($this->countX == $this->xNumber) {
+      // Page full, we start a new one
+      $this->AddPage();
+      $this->countX = 0;
+      $this->countY = 0;
+    }
+
     $posX = $this->marginLeft + ($this->countX * ($this->width + $this->xSpace));
     $posY = $this->marginTop + ($this->countY * ($this->height + $this->ySpace));
     $this->SetXY($posX + $this->paddingLeft, $posY + $this->paddingTop);
@@ -229,17 +236,6 @@ class CRM_Utils_PDF_Label extends TCPDF {
       $this->countX++;
       $this->countY = 0;
     }
-
-    if ($this->countX == $this->xNumber) {
-      // Page full, we start a new one
-      $this->countX = 0;
-      $this->countY = 0;
-    }
-
-    // We are in a new page, then we must add a page
-    if (($this->countX == 0) and ($this->countY == 0)) {
-      $this->AddPage();
-    }
   }
 
   function getFontNames() {