3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | This file is a part of CiviCRM. |
8 | CiviCRM is free software; you can copy, modify, and distribute it |
9 | under the terms of the GNU Affero General Public License |
10 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | CiviCRM is distributed in the hope that it will be useful, but |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
15 | See the GNU Affero General Public License for more details. |
17 | You should have received a copy of the GNU Affero General Public |
18 | License and the CiviCRM Licensing Exception along |
19 | with this program; if not, contact CiviCRM LLC |
20 | at info[AT]civicrm[DOT]org. If you have questions about the |
21 | GNU Affero General Public License or the licensing of CiviCRM, |
22 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
23 +--------------------------------------------------------------------+
29 * @copyright CiviCRM LLC (c) 2004-2013
35 * Class CRM_Badge_Format_Badge
37 * parent class for building name badges
39 class CRM_Badge_Format_Badge
{
40 function printImage($img) {
41 $x = $this->pdf
->GetAbsX();
42 $y = $this->pdf
->GetY();
47 $imgsize = getimagesize($img);
49 $f = $this->imgRes
/ 25.4;
50 $w = $imgsize[0] / $f;
51 $h = $imgsize[1] / $f;
52 $this->pdf
->Image($img, $this->pdf
->GetAbsX(), $this->pdf
->GetY(), $w, $h, '', '', '', FALSE, 72, '', FALSE, FALSE, FALSE, FALSE, FALSE, FALSE);
54 $this->pdf
->SetXY($x, $y);
58 * This function is called to create name label pdf
60 * @param array $participants associated array with participant info
61 * @param array $layoutInfo associated array which contains meta data about format/layout
66 function createLabels(&$participants, &$layoutInfo) {
67 $this->pdf
= new CRM_Utils_PDF_Label($layoutInfo['format'], 'mm');
69 $this->pdf
->setPrintHeader(FALSE);
70 $this->pdf
->setPrintFooter(FALSE);
71 $this->pdf
->AddPage();
72 $this->pdf
->AddFont('DejaVu Sans', '', 'DejaVuSans.php');
73 $this->pdf
->SetFont('DejaVu Sans');
74 $this->pdf
->SetGenerator($this, "generateLabel");
76 foreach ($participants as $participant) {
77 $formattedRow = self
::formatLabel($participant, $layoutInfo);
78 $this->pdf
->AddPdfLabel($formattedRow);
81 $this->pdf
->Output(CRM_Utils_String
::munge($layoutInfo['title'], '_', 64) . '.pdf', 'D');
82 CRM_Utils_System
::civiExit(1);
86 * Funtion to create structure and add meta data according to layout
88 * @param array $row row element that needs to be formatted
89 * @param array $layout layout meta data
91 * @return array $formattedRow row with meta data
93 static function formatLabel(&$row, &$layout) {
94 $formattedRow = array();
95 if (CRM_Utils_Array
::value('rowElements', $layout['data'])) {
96 foreach($layout['data']['rowElements'] as $key => $element) {
97 $formattedRow['token'][$key] = array(
98 'value' => $row[$element],
99 'font_name' => $layout['data']['font_name'][$key],
100 'font_size' => $layout['data']['font_size'][$key],
101 'text_alignment' => $layout['data']['text_alignment'][$key],
106 if (CRM_Utils_Array
::value('image_1', $layout['data'])) {
107 $formattedRow['image_1'] = $layout['data']['image_1'];
110 if (CRM_Utils_Array
::value('image_2', $layout['data'])) {
111 $formattedRow['image_2'] = $layout['data']['image_2'];
114 if (CRM_Utils_Array
::value('add_barcode', $layout['data'])) {
115 $formattedRow['barcode'] = $layout['data']['barcode_alignment'];
118 return $formattedRow;