Example #1
0
 /**
  * Init function
  */
 function __construct($json)
 {
     require 'mc_table.php';
     parent::__construct($json);
     // Get Config
     $conf = isset($_SESSION['pluginsConfig']) && isset($_SESSION['pluginsConfig']['export']) && isset($_SESSION['pluginsConfig']['export']['PDF']) ? $_SESSION['pluginsConfig']['export'] : array('PDF' => array());
     $defaultFont = isset($conf['PDF']['defaultFont']) ? $conf['PDF']['defaultFont'] : 'FreeSans';
     $defaultFontSize = isset($conf['PDF']['defaultFontSize']) ? $conf['PDF']['defaultFontSize'] : 9;
     $headerFont = isset($conf['PDF']['headerFont']) ? $conf['PDF']['headerFont'] : $defaultFont;
     $headerFontSize = isset($conf['PDF']['headerFontSize']) ? $conf['PDF']['headerFontSize'] : $defaultFontSize;
     $headerFontStyle = isset($conf['PDF']['headerFontStyle']) ? $conf['PDF']['headerFontStyle'] : '';
     $layerFont = isset($conf['PDF']['layerFont']) ? $conf['PDF']['layerFont'] : $defaultFont;
     $layerFontSize = isset($conf['PDF']['layerFontSize']) ? $conf['PDF']['layerFontSize'] : $defaultFontSize;
     $layerFontStyle = isset($conf['PDF']['layerFontStyle']) ? $conf['PDF']['layerFontStyle'] : '';
     // Write to table
     $pdf = new PDF_MC_Table();
     // only for tcpdf version >= 3
     // - font not well defined --> errors
     // - header and footer printed = lines on top and bottom
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->Open();
     $groups = (array) $this->jsonList[0];
     foreach ($groups as $grp) {
         $ret = $this->prepareData4PDF($grp);
         $colsPerc = $ret[0];
         $data = $ret[1];
         $header = $data['header'];
         $records = $data['records'];
         $pdfW = 180;
         // orientation detection
         $orientation = 'P';
         $colsum = $ret[2];
         $maxSize = max($headerFontSize, $defaultFontSize);
         $widthTmp = $colsum * $maxSize / 4;
         if ($widthTmp > 1.5 * $pdfW) {
             $pdfW = 270;
             $orientation = 'L';
         }
         $pdf->AddPage($orientation);
         $cols = array();
         foreach ($colsPerc as $cp) {
             $cols[] = $cp * $pdfW;
         }
         // add group name:
         $pdf->SetFont($layerFont, $layerFontStyle, $layerFontSize);
         $x = $pdf->GetX();
         $y = $pdf->GetY();
         $pdf->Cell(0, 0, $grp->description);
         $pdf->SetXY($x, $y + 9);
         // Calculate column widths
         $pdf->SetWidths($cols);
         // Add header
         $pdf->SetFont($headerFont, $headerFontStyle, $headerFontSize);
         $pdf->Row($header);
         // Add records
         $pdf->SetFont($defaultFont, '', $defaultFontSize);
         foreach ($records as $row) {
             $pdf->Row($row);
         }
     }
     $pdfFilePath = $this->tempFilePath . '.pdf';
     $this->tempFileLocation .= '.pdf';
     $pdf->Output($pdfFilePath, 'F');
 }
$pdf->AddFont('GillSans', 'L', 'GillSans_L.php');
$pdf->AddFont('GillSans', 'LI', 'GillSans_LI.php');
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetLeftMargin(25);
//----------------------------------------------
$pdf->SetFont('GillSans', '', 10);
$pdf->SetFillColor(249, 250, 252);
$pdf->Cell(70, 4, ' Estructura Programática ', 0, 0, 'L', 0);
$pdf->Cell(70, 4, 'Ejercicio: 2015 ', 0, 0, 'L', 0);
$pdf->Ln(5);
$pdf->SetFont('GillSans', 'B', 10);
$pdf->Cell(240, 4, 'Catálogo de Programas', 1, 1, 'C', 1);
$pdf->SetFont('GillSans', '', 10);
$y = $pdf->GetY();
$x = $pdf->GetX();
$pdf->MultiCell(20, 8, 'ID', 1, 'C', 1);
$pdf->SetXY($x + 20, $y);
$pdf->MultiCell(40, 8, 'Clave', 1, 'C', 1);
$pdf->SetXY($x + 60, $y);
$pdf->MultiCell(150, 8, 'Descripción', 1, 'C', 1);
$pdf->SetXY($x + 210, $y);
$pdf->Cell(30, 8, 'Tipo', 1, 0, 'C', 1);
$pdf->Cell(0, 4, '', 0, 1, 'C', 0);
$pdf->Ln(4);
//ciclo
$pdf->SetFont('GillSans', 'L', 12);
$pdf->SetWidths(array(20, 40, 150, 30));
foreach ($avPrg as $key => $value) {
    $c1 = $key;
    $c2 = $value['cve'];