function XML2PDF($debug = FALSE) { // Initialization $this->DebugPrint("initializing..."); parent::PDF_Unicode(); $this->debug = $debug; $this->abort_error = FALSE; $this->open_tags = array("page" => FALSE); $this->fontstack = array(); $this->colorstack = array(); $this->tablestack = array(); $this->trstack = array(); $this->tdstack = array(); $this->links = array(); $this->add_fonts = array(); $this->indent = array("ih1" => 0, "ih2" => 5, "ih3" => 10, "ih4" => 15, "ih5" => 20, "ih6" => 25, "current" => 0); $this->headingFont = array("H1" => 36, "H2" => 24, "H3" => 18, "H4" => 16, "H5" => 14, "H6" => 12); $this->headingSpace = array("H1" => 5, "H2" => 4, "H3" => 3, "H4" => 2, "H5" => 1, "H6" => 0); $this->AddUniGBFont('uGB'); $this->SetFont('uGB', '', 12); }
function index() { // define('FPDF_FONTPATH','/Users/easthero/Sites/pdf/font/'); include Kohana::find_file('helpers', 'fpdf/chinese-unicode'); $pdf = new PDF_Unicode(); $pdf->Open(); $pdf->AddPage(); $pdf->AddUniGBhwFont('msyh', '微软雅黑'); $pdf->SetFont('msyh', '', 20); $operationlog_orm = ORM::factory('operationlog')->find_all(); foreach ($operationlog_orm as $object) { $time = $object->occur_time; $time = date("Y-m-d H:i:s", $time); $pdf->Write(12, $time); $pdf->Write(12, $object->user_id); $pdf->Write(12, $object->from_ip); $pdf->Write(12, $object->description); $pdf->Ln(); } $pdf->Output(); }