/** * function to create labels (pdf) * * @param array $contactRows assciated array of contact data * @param string $format format in which labels needs to be printed * * @return null * @access public */ function createLabel(&$contactRows, &$format) { require_once 'CRM/Utils/String.php'; require_once 'CRM/Utils/PDF/Label.php'; $pdf = new CRM_Utils_PDF_Label($format, 'mm'); $pdf->Open(); $pdf->AddPage(); $pdf->AddFont('DejaVu Sans', '', 'DejaVuSans.php'); $pdf->SetFont('DejaVu Sans'); //build contact string that needs to be printed $val = null; foreach ($contactRows as $row => $value) { foreach ($value as $k => $v) { $val .= "{$v}\n"; } $pdf->AddPdfLabel($val); $val = ''; } $pdf->Output('MailingLabels_CiviCRM.pdf', 'D'); }