/** * function to create labels (pdf) * * @param array $contactRows assciated array of contact data * @param string $format format in which labels needs to be printed * @param string $fileName The name of the file to save the label in * * @return null * @access public */ static function createLabel(&$contactRows, &$format, $fileName = 'MailingLabels_CiviCRM.pdf') { $pdf = new CRM_Utils_PDF_Label($format, 'mm'); $pdf->Open(); $pdf->AddPage(); //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($fileName, 'D'); }
/** * 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'); }