Ejemplo n.º 1
0
 function exportPDF()
 {
     global $i18n, $ClassDir;
     require_once 'fpdf/PDF_Chinese.php';
     require_once $ClassDir . 'StringHelper.class.php';
     $header = array("name" => "20", "gender" => "12", "birthday" => "25", "mobile" => "30", "phone" => "30", "office_phone" => "30", "fax" => "30", "addrees" => "20");
     $pdf = new PDF_Chinese();
     $pdf->AddGBFont('simsun', 'ËÎÌå');
     $pdf->AddGBFont('simhei', 'ºÚÌå');
     $pdf->AddGBFont('simkai', '¿¬Ìå_GB2312');
     $pdf->AddGBFont('sinfang', '·ÂËÎ_GB2312');
     $pdf->Open();
     $pdf->SetMargins(5, 20, 5);
     $pdf->AddPage();
     $pdf->SetAutoPageBreak("on", 20);
     $pdf->SetFont('simsun', '', 16);
     $pdf->Cell(0, 20, $i18n->_('Contact'), 0, 1, 'C');
     foreach ($header as $title => $lenght) {
         $header_title_arr[] = $i18n->_(StringHelper::CamelCaseFromUnderscore($title));
     }
     // Write header
     $pdf->SetFont('simsun', 'B', 7);
     $pdf->SetWidths(array_values($header));
     $pdf->Row(array_values($header_title_arr));
     // Write contact record
     $pdf->SetFont('simsun', '', 7);
     $apf_contact = DB_DataObject::factory('ApfContact');
     $apf_contact->orderBy('id desc');
     $apf_contact->find();
     $i = 0;
     $page_rows = 30;
     while ($apf_contact->fetch()) {
         $i % $page_rows == 0 && $i ? $pdf->AddPage() : "";
         $coloum_data = array();
         foreach ($header as $title => $lenght) {
             $coloum_function = "get" . StringHelper::CamelCaseFromUnderscore($title);
             $coloum_data[] = $apf_contact->{$coloum_function}();
         }
         $pdf->Row(array_values($coloum_data));
         $i++;
     }
     $pdf->SetFont('Arial', '', 9);
     $pdf->AliasNbPages();
     $filename = date("Y_m_d") . "_contact_export.pdf";
     $pdf->Output($filename, true);
     exit;
 }