} $full_listing[$reccord['id']] = array('id' => $reccord['id'], 'label' => $reccord['label'], 'pw' => substr(addslashes($pw), strlen($reccord['rand_key'])), 'login' => $reccord['login']); } } $id_managed = $reccord['id']; } } } //Build PDF if (!empty($full_listing)) { //Prepare the PDF file include '../includes/libraries/tfpdf/tfpdf.php'; $pdf = new tFPDF(); //Add font for utf-8 $pdf->AddFont('DejaVu', '', 'DejaVuSansCondensed.ttf', true); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont('DejaVu', '', 16); $pdf->Cell(0, 10, $txt['print_out_pdf_title'], 0, 1, 'C', false); $pdf->SetFont('DejaVu', '', 12); $pdf->Cell(0, 10, $txt['pdf_del_date'] . " " . date($_SESSION['settings']['date_format'] . " " . $_SESSION['settings']['time_format'], mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"))) . ' ' . $txt['by'] . ' ' . $_SESSION['login'], 0, 1, 'C', false); $pdf->SetFont('DejaVu', '', 10); $pdf->SetFillColor(192, 192, 192); $pdf->cell(65, 6, $txt['label'], 1, 0, "C", 1); $pdf->cell(55, 6, $txt['login'], 1, 0, "C", 1); $pdf->cell(70, 6, $txt['pw'], 1, 1, "C", 1); $pdf->SetFont('DejaVu', '', 9); foreach ($full_listing as $item) { $pdf->cell(65, 6, stripslashes($item['label']), 1, 0, "L"); $pdf->cell(55, 6, stripslashes($item['login']), 1, 0, "C"); $pdf->cell(70, 6, stripslashes($item['pw']), 1, 1, "C");
/** * * Static ! not sure why!? * */ static function construct($svg, $data = array()) { if (is_object($data)) { $data = (array) $data; } $t = new XML_SvgToPDF(); $t->language = @$data['language']; /* $x = new XML_Tree_Morph( $svg, array( 'debug' => 0, 'filter' => array( 'svg' => array(&$t, 'buildObject'), 'image' => array(&$t, 'buildObject'), 'text' => array(&$t, 'buildObject'), 'tspan' => array(&$t, 'buildObject'), 'rect' => array(&$t, 'buildObject'), 'g' => array(&$t, 'buildObject'), 'path' => array(&$t, 'buildObject'), 'sodipodi:namedview' => array(&$t, 'buildNull'), 'defs' => array(&$t, 'buildNull'), ) ) ); $tree = $x->getTreeFromFile(); $tree = $t->buildobject($tree); */ //echo "<PRE>"; $tree = $t->parseSvg($svg); //echo "<PRE>";print_r($tree);exit; //echo "<PRE>";print_r($tree);exit; $orientation = preg_replace('/[^0-9.]+/', '', $tree->width) * 1 > preg_replace('/[^0-9.]+/', '', $tree->height) * 1 ? 'L' : 'P'; //var_dump($orientation);exit; $GLOBALS['_XML_SVGTOPDF']['options']['file'] = $svg; if (@$data['language'] == 'big5') { //die("trying chinese"); require_once 'Fpdf/tFPDF.php'; $pdf = new tFPDF($orientation, 'mm', 'A4'); // we originally used ARIALUNI.ttf' $font = '/usr/share/fonts/truetype/msttcorefonts/Arial.ttf'; if (!file_exists('/usr/share/fonts/truetype/msttcorefonts/Arial.ttf')) { die("install msttcorefonts package"); } //$pdf->AddFont('ARIALUNI','',$font,true); $pdf->AddFont('ARIALUNI', '', '/usr/share/fonts/truetype/msttcorefonts/Arial.ttf', true); $pdf->AddFont('ARIALUNI', 'B', '/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf', true); // $pdf->SetFont('ARIALUNI','',14); // require_once 'Fpdf/Chinese-unicode.php'; // // $pdf=new PDF_Unicode($orientation ,'mm','A4'); //// $pdf->AddGBFont(); //// $pdf->AddBig5Font(); // $pdf->AddUniCNSFont('Uni'); //$pdf->AddUniCNSFont('Uni'); //AddUniCNShwFont $pdf->open(); } else { $pdf = new tFPDF($orientation, 'mm', 'A4'); $pdf->open(); } $pdf->setAutoPageBreak(false); $pdf->AliasNbPages(); // convert data to array. if (is_object($data)) { $data = (array) $data; } // assoc. array of key => no of fields per page. $perPage = $tree->calcPerPage(); //list($var,$perpage) = $tree->calcPerPage(); //if (empty($data) || !@$var || !@count($data[$var])) { // print_r("<PRE>"); // print_r($data['transactions'][0]); // $data['transactions'][0]->desc = 'abcdefghijklmnopqrstuvwxyz Z'; // print_r($data['transactions'][0]->desc); // no dynamic blocks: if (!$perPage || empty($data)) { $pdf->addPage(); $tree->writePDF($pdf, $data); $t->debug($tree); return $pdf; } // build blocks of data for each page. $haveData = true; $page = 0; // $originalData = $data; //$alldata = $data[$var]; // while (count($alldata)) { //print_r($perPage);exit; while (true == $haveData) { $page_data = $data; $haveData = false; //print_r($perPage); // replaces the properties that have 'page data' foreach ($perPage as $k => $v) { if (empty($data[$k])) { $page_data[$k] = array(); continue; } $haveData = true; $page_data[$k] = self::fetchRows($data, $k, $v); //$page_data[$k] = array_splice ( $data[$k], 0,$v); } if ($page && !$haveData) { break; } $page++; $t->debug("<B>PAGE {$page}<B>"); $pdf->addPage(); $tree->writePDF($pdf, $page_data); //$tree->writePDF($pdf,$data); } $t->debug($tree); return $pdf; }