Different fonts with TCPDF

Hi,
I am rtrying to use two different fonts within the one generated pdf. The second font is needs to display check marks.

Here is the code,

if (isset($_POST['pdf']) and $_POST['pdf']=='Generate PDF')
    {
require_once($_SERVER['DOCUMENT_ROOT'] . '/artgibney/tcpdf/examples/tcpdf_include.php');
include $_SERVER['DOCUMENT_ROOT'] . '/artgibney/includes/buildlearners.inc.php'; 
include_once $_SERVER['DOCUMENT_ROOT'] . '/artgibney/includes/helpers.inc.php';
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);

PDF_HEADER_TITLE.’ 001’, PDF_HEADER_STRING, array(0,64,255), array(0,64,128));

$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
    require_once(dirname(__FILE__).'/lang/eng.php');
    $pdf->setLanguageArray($l);
}
$pdf->setFontSubsetting(true);
$checkMarkFont = $pdf->SetFont('zapfdingbats', '', 11, '', true);
$pdf->SetFont('dejavusans', '', 11, '', true);
$pdf->AddPage();
$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));

$result = unserialize($_POST['result']);
$student = $_POST['student'];
$html =  '<h2>' . $student . '</h2><table><tr>';
    foreach($result as $keys => $values): 
           if($keys == 0): 
             foreach($values as $key => $value):
           if($key != 'id'):
         $html .= '<th> '. $key . '</th>';
             endif; 
           endforeach; 
           endif;
          endforeach; 
      $html .= '</tr>';
      foreach($result as $keys => $values):
      $html .= '<tr>';
    foreach($values as $key => $value):
          if($key != 'id'):
        $html .= '<td>';
            if((is_numeric($value))&&($value==1)&&($key!='effort')):
          $html .= '<span style="font-family : ' . $checkMarkFont . ';">4</span>';
        elseif((is_numeric($value))&&($value==0)):
        else:
        $html .= $value;
             endif;
            $html .= '</td>';
             else:
                 endif; 
            endforeach; 
            $html .= '</tr>';
            endforeach;       
     $html .= '</table>';    
$pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
$pdf->Output($student . '.pdf', 'I');
        exit();
}

I can’t see why it doesn’t change the font.
Thanks,
Shane

Hi,
I figured it out, the line,

$html .= '<span style="font-family : ' . $checkMarkFont . ';">4</span>';

should be

$html .= '<font face="zapfdingbats">4</font>'; 

Thanks,
shane

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.