Exemple #1
1
 /**
  * Genera un archivo PDF con la información de las empresas que recibe como parámetro
  * @param	$s(0/1/2/)	string	con las (ESP/Empresas/Ciudadanos) seleccionadas
  * @param	$ruta_raiz	string	con el path a la raiz de ORFEO
  * @param	$archivo	string	con el archivo a crear
  * @param	$sc(0/1/2)	string	con los contactos de las (ESP/Empresas/Ciudadanos) seleccionados
   * @return   string
 */
 function generarPDF($s0, $ruta_raiz, $archivo, $sc0, $s1 = null, $s2 = null, $sc1 = null, $sc2 = null)
 {
     $pdf = new Cezpdf("LETTER", "landscape");
     $justCentro = array("justification" => "center");
     $estilo1 = array("justification" => "left", "leading" => 8);
     $estilo2 = array("left" => 0, "leading" => 12);
     $estilo3 = array("left" => 0, "leading" => 15);
     $pdf->ezSetCmMargins(4, 3, 4, 2);
     //top,botton,left,right
     // Se establece la fuente que se utilizara para el texto.
     $pdf->selectFont($ruta_raiz . "/include/pdf/fonts/Times-Roman.afm");
     $pdf->ezText("LISTADO PREVIO REGISTROS SELECCIONADOS\n\n", 15, $justCentro);
     $txtformat = "Se ha seleccionado:";
     $data = array();
     $y = 0;
     //variable que almacena el caracter comilla
     $com = chr(34);
     //variable que almacena el contenido del archivo
     $contenido = "{$com}*TIPO*{$com},{$com}*NOMBRE*{$com},{$com}*DIR*{$com},{$com}*MUNI_NOMBRE*{$com},{$com}*DEPTO_NOMBRE*{$com},{$com}*PAIS_NOMBRE*{$com},{$com}*NUIR*{$com},{$com}*NOMBRE_REP*{$com},{$com}*DIGNATARIO*{$com},{$com}*CARGO*{$com}\n";
     $depto =& new Departamento($this->cursor);
     $muni =& new Municipio($this->cursor);
     for ($i = 0; $i < 3; $i++) {
         if (${'s' . $i}) {
             //arreglo con las empresas seleccionadas
             $arrEmpresas = explode(",", ${'s' . $i});
             $arrContacto = explode(",", ${'sc' . $i});
             //variable que almacena la cantidad de empresas que llegarom como parámetro
             $num = count($arrEmpresas);
             $x = 0;
             //Se recorre el arreglo de las empresas para armar el IN dentro del where de la búsqueda
             while ($x < $num) {
                 $nuir = $arrEmpresas[$x];
                 if (strlen(trim($nuir)) > 0) {
                     if (strlen($selectedSQL)) {
                         $selectedSQL = $selectedSQL . "," . "'{$nuir}'";
                     } else {
                         $selectedSQL = "'{$nuir}'";
                     }
                 }
                 $x++;
             }
             //query final
             switch ($i) {
                 case 0:
                     $q = "select ID_PAIS AS IDPAIS,CODIGO_DEL_DEPARTAMENTO AS IDDPTO,CODIGO_DEL_MUNICIPIO AS IDMPIO,\n\t  \t\t\t\t\t\tNOMBRE_DE_LA_EMPRESA AS PPAL,DIRECCION AS DIR,NUIR AS ID,NOMBRE_REP_LEGAL AS DESCR\n\t  \t\t\t\t\tfrom BODEGA_EMPRESAS where NUIR in ({$selectedSQL}) ORDER BY CODIGO_DEL_DEPARTAMENTO, CODIGO_DEL_MUNICIPIO, NOMBRE_DE_LA_EMPRESA";
                     break;
                 case 1:
                     $q = "select ID_PAIS AS IDPAIS,DPTO_CODI AS IDDPTO,MUNI_CODI AS IDMPIO,SGD_OEM_OEMPRESA AS PPAL,\n\t  \t\t\t\t\t\tSGD_OEM_DIRECCION AS DIR,SGD_OEM_CODIGO AS ID,SGD_OEM_REP_LEGAL AS DESCR\n\t  \t\t\t\t\tfrom SGD_OEM_OEMPRESAS where SGD_OEM_CODIGO in ({$selectedSQL}) ORDER BY IDDPTO, IDMPIO, SGD_OEM_OEMPRESA";
                     break;
                 case 2:
                     $q = "select ID_PAIS AS IDPAIS,DPTO_CODI AS IDDPTO,MUNI_CODI AS IDMPIO,SGD_CIU_NOMBRE AS PPAL,\n\t  \t\t\t\t\t\tSGD_CIU_DIRECCION AS DIR,SGD_CIU_CODIGO AS ID,SGD_CIU_APELL2  AS DESCR\n\t  \t\t\t\t\tfrom SGD_CIU_CIUDADANO where SGD_CIU_CODIGO in ({$selectedSQL}) ORDER BY IDDPTO, IDMPIO, SGD_CIU_NOMBRE";
                     break;
             }
             $selectedSQL = "";
             $rs = $this->cursor->query($q);
             while (!$rs->EOF) {
                 $y++;
                 $paisCodi = $rs->fields['IDPAIS'];
                 $codDepto = $paisCodi . '-' . $rs->fields['IDDPTO'];
                 $codMuni = $codDepto . '-' . $rs->fields['IDMPIO'];
                 $depto->departamento_codigo($codDepto);
                 $muni->municipio_codigo($codDepto, $codMuni);
                 $nombDepto = $depto->get_dpto_nomb();
                 $nombMuni = $muni->get_muni_nomb();
                 // Trae nombre del pais
                 $tmp_rs = $this->cursor->query("SELECT NOMBRE_PAIS FROM SGD_DEF_PAISES WHERE ID_PAIS=" . $paisCodi);
                 if ($tmp_rs) {
                     trim($tmp_rs->fields['NOMBRE_PAIS']) == "" ? $nombPais = "<ESPACIO>" : ($nombPais = $tmp_rs->fields['NOMBRE_PAIS']);
                     $tmp_rs->Close();
                     unset($tmp_rs);
                 } else {
                     $nombPais = "<ESPACIO>";
                 }
                 $nombESP = $rs->fields['PPAL'];
                 $dirESP = $rs->fields['DIR'];
                 $nuir = $rs->fields['ID'];
                 $nomRepESP = $rs->fields['DESCR'];
                 // Trae nombre del dignatario
                 reset($arrEmpresas);
                 $tmp_var = array_search($nuir, $arrEmpresas);
                 $tmp_vec = explode(",", ${'sc' . $i});
                 $tmp_rs = $this->cursor->query("SELECT CTT_NOMBRE,CTT_CARGO FROM SGD_DEF_CONTACTOS WHERE CTT_ID=" . $tmp_vec[$tmp_var]);
                 if ($tmp_rs) {
                     trim($tmp_rs->fields['CTT_NOMBRE']) == "" ? $dignatario = "<ESPACIO>" : ($dignatario = $tmp_rs->fields['CTT_NOMBRE']);
                     trim($tmp_rs->fields['CTT_CARGO']) == "" ? $cargo = "<ESPACIO>" : ($cargo = $tmp_rs->fields['CTT_CARGO']);
                     $tmp_rs->Close();
                     unset($tmp_rs);
                 } else {
                     $dignatario = "";
                 }
                 $contenido = $contenido . "{$i},{$com}{$nombESP}{$com},{$com}{$dirESP}{$com},{$com}{$nombMuni}{$com},{$com}{$nombDepto}{$com},{$com}{$nombPais}{$com},{$com}{$nuir}{$com},{$com}{$nomRepESP}{$com},{$com}{$dignatario}{$com},{$com}{$cargo}{$com}\n";
                 $data = array_merge($data, array(array('#' => $y, 'Tipo' => $i, 'Nombre' => $nombESP, 'Dirección' => $dirESP, 'País' => $nombPais, 'Departamento' => $nombDepto, 'Municipio' => $nombMuni, 'Nuir' => $nuir, 'Representante' => $nomRepESP, 'Dignatario' => $dignatario, 'Cargo' => $cargo)));
                 $rs->MoveNext();
             }
         }
     }
     $pdf->ezTable($data, '', '', array('fontSize' => 6, 'width' => 700));
     //Referencia el PDF a generar
     $pdfcode = $pdf->ezOutput();
     $fp = fopen($archivo, 'wb');
     fwrite($fp, $pdfcode);
     fclose($fp);
 }
Exemple #2
1
function upload_file_to_client_pdf($file_to_send)
{
    //Function reads a text file and converts to pdf.
    global $STMT_TEMP_FILE_PDF;
    $pdf = new Cezpdf('LETTER');
    //pdf creation starts
    $pdf->ezSetMargins(36, 0, 36, 0);
    $pdf->selectFont($GLOBALS['fileroot'] . "/library/fonts/Courier.afm");
    $pdf->ezSetY($pdf->ez['pageHeight'] - $pdf->ez['topMargin']);
    $countline = 1;
    $file = fopen($file_to_send, "r");
    //this file contains the text to be converted to pdf.
    while (!feof($file)) {
        $OneLine = fgets($file);
        //one line is read
        if (stristr($OneLine, "\f") == true && !feof($file)) {
            $pdf->ezNewPage();
            $pdf->ezSetY($pdf->ez['pageHeight'] - $pdf->ez['topMargin']);
            str_replace("\f", "", $OneLine);
        }
        if (stristr($OneLine, 'REMIT TO') == true || stristr($OneLine, 'Visit Date') == true) {
            //lines are made bold when 'REMIT TO' or 'Visit Date' is there.
            $pdf->ezText('<b>' . $OneLine . '</b>', 12, array('justification' => 'left', 'leading' => 6));
        } else {
            $pdf->ezText($OneLine, 12, array('justification' => 'left', 'leading' => 6));
        }
        $countline++;
    }
    $fh = @fopen($STMT_TEMP_FILE_PDF, 'w');
    //stored to a pdf file
    if ($fh) {
        fwrite($fh, $pdf->ezOutput());
        fclose($fh);
    }
    header("Pragma: public");
    //this section outputs the pdf file to browser
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-Type: application/force-download");
    header("Content-Length: " . filesize($STMT_TEMP_FILE_PDF));
    header("Content-Disposition: attachment; filename=" . basename($STMT_TEMP_FILE_PDF));
    header("Content-Description: File Transfer");
    readfile($STMT_TEMP_FILE_PDF);
    // flush the content to the browser. If you don't do this, the text from the subsequent
    // output from this script will be in the file instead of sent to the browser.
    flush();
    exit;
    //added to exit from process properly in order to stop bad html code -ehrlive
    // sleep one second to ensure there's no follow-on.
    sleep(1);
}
Exemple #3
0
 public function save($filename)
 {
     if ($filename) {
         if (file_exists($filename)) {
             unlink($filename);
         }
         $file = fopen($filename, 'a');
         if ($file) {
             fwrite($file, $this->pdf->ezOutput());
             fclose($file);
             return TRUE;
         } else {
             return TRUE;
         }
     } else {
         return FALSE;
     }
 }
Exemple #4
0
 function generar_pdf()
 {
     require_once toba_dir() . '/php/3ros/ezpdf/class.ezpdf.php';
     $pdf = new Cezpdf();
     $pdf->selectFont(toba_dir() . '/php/3ros/ezpdf/fonts/Helvetica.afm');
     $pdf->ezText('Ejemplo Firma Digital. Tiene dos attachments XML', 14);
     //-- Cuadro con datos
     $opciones = array('splitRows' => 0, 'rowGap' => 1, 'showHeadings' => true, 'titleFontSize' => 9, 'fontSize' => 10, 'shadeCol' => array(0.9, 0.9, 0.9), 'outerLineThickness' => 0.7, 'innerLineThickness' => 0.7, 'xOrientation' => 'center', 'width' => 500);
     $this->s__datos_juegos = toba::db()->consultar("SELECT * from ref_juegos");
     $pdf->ezTable($this->s__datos_juegos, '', 'Juegos', $opciones);
     $this->s__datos_deportes = toba::db()->consultar("SELECT * from ref_deportes");
     $pdf->ezTable($this->s__datos_deportes, '', 'Deportes', $opciones);
     $tmp = $pdf->ezOutput(0);
     $this->s__pdf = array();
     $sesion = get_firmador()->generar_sesion();
     $this->s__pdf['path'] = toba::proyecto()->get_path_temp() . "/doc{$sesion}_sinfirma.pdf";
     if (!file_put_contents($this->s__pdf['path'], $tmp)) {
         throw new toba_error("Imposible escribir en '{$this->s__pdf['path']}'. Chequee permisos");
     }
 }
Exemple #5
0
    $user = isset($_GET['user']) ? $_GET['user'] : '';
    $owner = isset($_GET['owner']) ? $_GET['owner'] : '';
    $mode = isset($_GET['mode']) && is_numeric($_GET['mode']) ? $_GET['mode'] : 1;
    $pdf->setEncryption($user, $owner, array(), $mode);
}
// select a font
$pdf->selectFont('Times-Roman');
$pdf->openHere('Fit');
$pdf->ezText("This example shows how to crypt the PDF document\n");
$pdf->ezText("\nUse \"?mode=1\" for RC4 40bit encryption\n");
$pdf->ezText("\nUse \"?mode=2\" for RC4 128bit encryption\n");
$pdf->ezText("\nUse \"?nocrypt\" to disable the encryption\n");
$pdf->ezText("\nUse \"?user=password\" to set a user password\n");
$pdf->ezText("\nUse \"?owner=password\" to set a owner password\n");
if (isset($_GET['nocrypt'])) {
    $pdf->ezText("<b>Not encrypt</b> - nocrypt parameter found");
}
if (isset($_GET['d']) && $_GET['d']) {
    echo $pdf->ezOutput(TRUE);
} else {
    if ($mode > 1) {
        $encMode = "128BIT";
    } else {
        if ($mode > 0) {
            $encMode = "40BIT";
        } else {
            $encMode = "NONE";
        }
    }
    $pdf->ezStream(array('Content-Disposition' => "encrypted_" . $encMode . (isset($_GET['user']) ? "_withUserPW" : "") . (isset($_GET['owner']) ? "_withOwnerPW" : ""), 'attached' => 0));
}
 function printPDF($p_params)
 {
     $pbConfig = new PluginBarcodeConfig();
     // create barcodes
     $ext = 'png';
     $type = $p_params['type'];
     $size = $p_params['size'];
     $orientation = $p_params['orientation'];
     $codes = array();
     if ($type == 'QRcode') {
         $codes = $p_params['codes'];
     } else {
         if (isset($p_params['code'])) {
             if (isset($p_params['nb']) and $p_params['nb'] > 1) {
                 $this->create($p_params['code'], $type, $ext);
                 for ($i = 1; $i <= $p_params['nb']; $i++) {
                     $codes[] = $p_params['code'];
                 }
             } else {
                 if (!$this->create($p_params['code'], $type, $ext)) {
                     Session::addMessageAfterRedirect(__('The generation of some bacodes produced errors.', 'barcode'));
                 }
                 $codes[] = $p_params['code'];
             }
         } elseif (isset($p_params['codes'])) {
             $codes = $p_params['codes'];
             foreach ($codes as $code) {
                 if ($code != '') {
                     $this->create($code, $type, $ext);
                 }
             }
         } else {
             // TODO : erreur ?
             //         print_r($p_params);
             return 0;
         }
     }
     // create pdf
     // x is horizontal axis and y is vertical
     // x=0 and y=0 in bottom left hand corner
     $config = $pbConfig->getConfigType($type);
     require_once GLPI_ROOT . "/plugins/barcode/lib/ezpdf/class.ezpdf.php";
     $pdf = new Cezpdf($size, $orientation);
     $pdf->selectFont(GLPI_ROOT . "/plugins/barcode/lib/ezpdf/fonts/Helvetica.afm");
     $pdf->ezStartPageNumbers($pdf->ez['pageWidth'] - 30, 10, 10, 'left', '{PAGENUM} / {TOTALPAGENUM}') . ($width = $config['maxCodeWidth']);
     $height = $config['maxCodeHeight'];
     $marginH = $config['marginHorizontal'];
     $marginV = $config['marginVertical'];
     $heightimage = $height;
     if (file_exists(GLPI_PLUGIN_DOC_DIR . '/barcode/logo.png')) {
         // Add logo to barcode
         $heightLogomax = 20;
         $imgSize = getimagesize(GLPI_PLUGIN_DOC_DIR . '/barcode/logo.png');
         $logoWidth = $imgSize[0];
         $logoHeight = $imgSize[1];
         if ($logoHeight > $heightLogomax) {
             $ratio = 100 * $heightLogomax / $logoHeight;
             $logoHeight = $heightLogomax;
             $logoWidth = $logoWidth * ($ratio / 100);
         }
         if ($logoWidth > $width) {
             $ratio = 100 * $width / $logoWidth;
             $logoWidth = $width;
             $logoHeight = $logoHeight * ($ratio / 100);
         }
         $heightyposText = $height - $logoHeight;
         $heightimage = $heightyposText;
     }
     $first = true;
     foreach ($codes as $code) {
         if ($first) {
             $x = $pdf->ez['leftMargin'];
             $y = $pdf->ez['pageHeight'] - $pdf->ez['topMargin'] - $height;
             $first = false;
         } else {
             if ($x + $width + $marginH > $pdf->ez['pageWidth']) {
                 // new line
                 $x = $pdf->ez['leftMargin'];
                 if ($y - $height - $marginV < $pdf->ez['bottomMargin']) {
                     // new page
                     $pdf->ezNewPage();
                     $y = $pdf->ez['pageHeight'] - $pdf->ez['topMargin'] - $height;
                 } else {
                     $y -= $height + $marginV;
                 }
             }
         }
         if ($code != '') {
             if ($type == 'QRcode') {
                 $imgFile = $code;
             } else {
                 $imgFile = $this->docsPath . $code . '_' . $type . '.' . $ext;
             }
             if (file_exists($imgFile)) {
                 $imgSize = getimagesize($imgFile);
                 $imgWidth = $imgSize[0];
                 $imgHeight = $imgSize[1];
                 if ($imgWidth > $width) {
                     $ratio = 100 * $width / $imgWidth;
                     $imgWidth = $width;
                     $imgHeight = $imgHeight * ($ratio / 100);
                 }
                 if ($imgHeight > $heightimage) {
                     $ratio = 100 * $heightimage / $imgHeight;
                     $imgHeight = $heightimage;
                     $imgWidth = $imgWidth * ($ratio / 100);
                 }
                 $image = imagecreatefrompng($imgFile);
                 if ($imgWidth < $width) {
                     $pdf->addImage($image, $x + ($width - $imgWidth) / 2, $y, $imgWidth, $imgHeight);
                 } else {
                     $pdf->addImage($image, $x, $y, $imgWidth, $imgHeight);
                 }
                 if (file_exists(GLPI_PLUGIN_DOC_DIR . '/barcode/logo.png')) {
                     $logoimg = imagecreatefrompng(GLPI_PLUGIN_DOC_DIR . '/barcode/logo.png');
                     $pdf->addImage($logoimg, $x + ($width - $logoWidth) / 2, $y + $heightyposText, $logoWidth, $logoHeight);
                 }
                 if ($p_params['border']) {
                     $pdf->Rectangle($x, $y, $width, $height);
                 }
             }
         }
         $x += $width + $marginH;
         $y -= 0;
     }
     $file = $pdf->ezOutput();
     $pdfFile = $_SESSION['glpiID'] . '_' . $type . '.pdf';
     file_put_contents($this->docsPath . $pdfFile, $file);
     return '/files/_plugins/barcode/' . $pdfFile;
 }
                $text = $pdf->openObject();
                $pdf->ezSetY(470);
                $pdf->ezSetMargins(0, 0, 200, 30);
                $pdf->ezText($date, 12, array('justification' => 'left'));
                $pdf->ezSetMargins(0, 0, 75, 75);
                $pdf->ezSetY(420);
                $pdf->ezText($team['place'] . '. plads', 40, array('justification' => 'center'));
                $pdf->ezText('', 20, array('justification' => 'center'));
                $pdf->ezSetY(250);
                $pdf->ezSetMargins(0, 0, 30, 30);
                $rsSwimmers = $db->diplomaTeamSwimmers($team['tid']);
                while ($swimmer = $db->fetch_array($rsSwimmers)) {
                    $pdf->ezText($swimmer['name'], 20, array('justification' => 'center'));
                }
                $pdf->ezText("i " . $team['distance'] . "m stafet", 14, array('justification' => 'center'));
                $pdf->closeObject();
                $pdf->addObject($text);
            }
        }
    }
    //header("Content-type: application/pdf");
    $pdfout = $pdf->ezOutput();
    $name = time();
    $fp = fopen('dump/' . $name . '.pdf', 'wb');
    fwrite($fp, $pdfout);
    fclose($fp);
    header("Location: dump/{$name}.pdf");
} else {
    echo 'ged';
}
$db->close();
Exemple #8
0
 function generate_invoice_file($verbose = false, $getfile = false)
 {
     // Build PDF document
     $font1 = ALLOC_MOD_DIR . "util/fonts/Helvetica.afm";
     $font2 = ALLOC_MOD_DIR . "util/fonts/Helvetica-Oblique.afm";
     $db = new db_alloc();
     // Get client name
     $client = $this->get_foreign_object("client");
     $clientName = $client->get_value("clientName");
     // Get cyber info
     $companyName = config::get_config_item("companyName");
     $companyNos1 = config::get_config_item("companyACN");
     $companyNos2 = config::get_config_item("companyABN");
     $phone = config::get_config_item("companyContactPhone");
     $fax = config::get_config_item("companyContactFax");
     $phone and $phone = "Ph: " . $phone;
     $fax and $fax = "Fax: " . $fax;
     $img = config::get_config_item("companyImage");
     $companyContactAddress = config::get_config_item("companyContactAddress");
     $companyContactAddress2 = config::get_config_item("companyContactAddress2");
     $companyContactAddress3 = config::get_config_item("companyContactAddress3");
     $email = config::get_config_item("companyContactEmail");
     $email and $companyContactEmail = "Email: " . $email;
     $web = config::get_config_item("companyContactHomePage");
     $web and $companyContactHomePage = "Web: " . $web;
     $footer = config::get_config_item("timeSheetPrintFooter");
     $taxName = config::get_config_item("taxName");
     if ($this->get_value("invoiceDateFrom") && $this->get_value("invoiceDateTo") && $this->get_value("invoiceDateFrom") != $this->get_value("invoiceDateTo")) {
         $period = format_date(DATE_FORMAT, $this->get_value("invoiceDateFrom")) . " to " . format_date(DATE_FORMAT, $this->get_value("invoiceDateTo"));
     } else {
         $period = format_date(DATE_FORMAT, $this->get_value("invoiceDateTo"));
     }
     $default_header = "Tax Invoice";
     $default_id_label = "Invoice Number";
     $pdf_table_options = array("showLines" => 0, "shaded" => 0, "showHeadings" => 0, "xPos" => "left", "xOrientation" => "right", "fontSize" => 10, "rowGap" => 0, "fontSize" => 10);
     $cols = array("one" => "", "two" => "", "three" => "", "four" => "");
     $cols3 = array("one" => "", "two" => "");
     $cols_settings["one"] = array("justification" => "right");
     $cols_settings["three"] = array("justification" => "right");
     $pdf_table_options2 = array("showLines" => 0, "shaded" => 0, "showHeadings" => 0, "width" => 400, "fontSize" => 10, "xPos" => "center", "xOrientation" => "center", "cols" => $cols_settings);
     $cols_settings2["gst"] = array("justification" => "right");
     $cols_settings2["money"] = array("justification" => "right");
     $cols_settings2["unit"] = array("justification" => "right");
     $pdf_table_options3 = array("showLines" => 2, "shaded" => 0, "width" => 400, "xPos" => "center", "fontSize" => 10, "cols" => $cols_settings2, "lineCol" => array(0.8, 0.8, 0.8), "splitRows" => 1, "protectRows" => 0);
     $cols_settings["two"] = array("justification" => "right", "width" => 80);
     $pdf_table_options4 = array("showLines" => 2, "shaded" => 0, "width" => 400, "showHeadings" => 0, "fontSize" => 10, "xPos" => "center", "cols" => $cols_settings, "lineCol" => array(0.8, 0.8, 0.8));
     $pdf = new Cezpdf();
     $pdf->ezSetMargins(90, 90, 90, 90);
     $pdf->selectFont($font1);
     $pdf->ezStartPageNumbers(436, 80, 10, 'right', 'Page {PAGENUM} of {TOTALPAGENUM}');
     $pdf->ezStartPageNumbers(200, 80, 10, 'left', '<b>' . $default_id_label . ': </b>' . $this->get_value("invoiceNum"));
     $pdf->ezSetY(775);
     $companyName and $contact_info[] = array($companyName);
     $companyContactAddress and $contact_info[] = array($companyContactAddress);
     $companyContactAddress2 and $contact_info[] = array($companyContactAddress2);
     $companyContactAddress3 and $contact_info[] = array($companyContactAddress3);
     $companyContactEmail and $contact_info[] = array($companyContactEmail);
     $companyContactHomePage and $contact_info[] = array($companyContactHomePage);
     $phone and $contact_info[] = array($phone);
     $fax and $contact_info[] = array($fax);
     $pdf->selectFont($font2);
     $y = $pdf->ezTable($contact_info, false, "", $pdf_table_options);
     $pdf->selectFont($font1);
     $line_y = $y - 10;
     $pdf->setLineStyle(1, "round");
     $pdf->line(90, $line_y, 510, $line_y);
     $pdf->ezSetY(782);
     $image_jpg = ALLOC_LOGO;
     if (file_exists($image_jpg)) {
         $pdf->ezImage($image_jpg, 0, sprintf("%d", config::get_config_item("logoScaleX")), 'none');
         $y = 700;
     } else {
         $y = $pdf->ezText($companyName, 27, array("justification" => "right"));
     }
     $nos_y = $line_y + 22;
     $companyNos2 and $nos_y = $line_y + 34;
     $pdf->ezSetY($nos_y);
     $companyNos1 and $y = $pdf->ezText($companyNos1, 10, array("justification" => "right"));
     $companyNos2 and $y = $pdf->ezText($companyNos2, 10, array("justification" => "right"));
     $pdf->ezSetY($line_y - 20);
     $y = $pdf->ezText($default_header, 20, array("justification" => "center"));
     $pdf->ezSetY($y - 20);
     $ts_info[] = array("one" => "<b>" . $default_id_label . ":</b>", "two" => $this->get_value("invoiceNum"), "three" => "<b>Date Issued:</b>", "four" => date("d/m/Y"));
     $ts_info[] = array("one" => "<b>Client:</b>", "two" => $clientName, "three" => "<b>Billing Period:</b>", "four" => $period);
     $y = $pdf->ezTable($ts_info, $cols, "", $pdf_table_options2);
     $pdf->ezSetY($y - 20);
     list($rows, $info) = $this->get_invoiceItem_list_for_file($verbose);
     $cols2 = array("desc" => "Description", "quantity" => "Qty", "unit" => "Unit Price", "money" => "Charges", "gst" => $taxName);
     $taxPercent = config::get_config_item("taxPercent");
     if ($taxPercent === '') {
         unset($cols2["gst"]);
     }
     $rows[] = array("desc" => "<b>TOTAL</b>", "money" => $info["total"], "gst" => $info["total_gst"]);
     $y = $pdf->ezTable($rows, $cols2, "", $pdf_table_options3);
     $pdf->ezSetY($y - 20);
     if ($taxPercent !== '') {
         $totals[] = array("one" => "TOTAL " . $taxName, "two" => $info["total_gst"]);
     }
     $totals[] = array("one" => "TOTAL CHARGES", "two" => $info["total"]);
     $totals[] = array("one" => "<b>TOTAL AMOUNT PAYABLE</b>", "two" => "<b>" . $info["total_inc_gst"] . "</b>");
     $y = $pdf->ezTable($totals, $cols3, "", $pdf_table_options4);
     $pdf->ezSetY($y - 20);
     $pdf->ezText(str_replace(array("<br>", "<br/>", "<br />"), "\n", $footer), 10);
     // Add footer
     #$all = $pdf->openObject();
     #$pdf->saveState();
     #$pdf->addText(415,80,12,"<b>".$default_id_label.":</b>".$this->get_value("invoiceNum"));
     #$pdf->restoreState();
     #$pdf->closeObject();
     #$pdf->addObject($all,'all');
     if ($getfile) {
         return $pdf->ezOutput();
     } else {
         $pdf->ezStream(array("Content-Disposition" => "invoice_" . $this->get_id() . ".pdf"));
     }
 }
Exemple #9
0
 function generar_pdf()
 {
     $datos = $this->get_datos_persona();
     $temp = rand();
     $datos_persona = array();
     $datos_persona['id'] = $datos['id'];
     $datos_persona['nombre'] = $datos['nombre'];
     $datos_persona['fecha_nac'] = $datos['fecha_nac'];
     //Generar PDF
     require_once toba_dir() . '/php/3ros/ezpdf/class.ezpdf.php';
     $pdf = new Cezpdf();
     $pdf->selectFont(toba_dir() . '/php/3ros/ezpdf/fonts/Helvetica.afm');
     $pdf->ezText('Ejemplo Firma Digital. Tiene un attachment XML', 14);
     $pdf->ezText('');
     $pdf->ezText("ID: {$datos['id']}", 14);
     $pdf->ezText("Nombre: {$datos['nombre']}", 14);
     $pdf->ezText("Fecha Nacimiento: {$datos['fecha_nac']}", 14);
     //Guardarlo en un archivo temporal
     $pdf_persona = toba::proyecto()->get_path_temp() . "/{$temp}.pdf";
     file_put_contents($pdf_persona, $pdf->ezOutput(0));
     //Generar XML
     $xml_persona = toba::proyecto()->get_path_temp() . "/{$temp}.xml";
     $xml = new toba_xml_tablas();
     $xml->set_tablas($datos_persona, "persona");
     $xml->guardar($xml_persona);
     //Agrego XMLs a PDF
     toba_firma_digital::pdf_add_attachments($pdf_persona, array($xml_persona));
     //Actualizo tabla
     $this->guardar_pdf_en_tabla($pdf_persona, false);
     //Retorno PDF y borro temporales
     $retorno = file_get_contents($pdf_persona);
     unlink($pdf_persona);
     unlink($xml_persona);
     return $retorno;
 }
Exemple #10
0
<?php

//header('Content-type: application/pdf');
//header("Content-Type: application/force-download");
require 'class.ezpdf.php';
$pdf = new Cezpdf();
$pdf->selectFont('fonts/Helvetica.afm');
$pdf->ezText('Hello World!', 50);
$pdf->ezStream();
$pdf->ezOutput();
function upload_file_to_client_pdf($file_to_send)
{
    //Function reads a HTML file and converts to pdf.
    global $STMT_TEMP_FILE_PDF;
    global $srcdir;
    if ($GLOBALS['statement_appearance'] == '1') {
        require_once "{$srcdir}/html2pdf/vendor/autoload.php";
        $pdf2 = new HTML2PDF($GLOBALS['pdf_layout'], $GLOBALS['pdf_size'], $GLOBALS['pdf_language'], true, 'UTF-8', array($GLOBALS['pdf_left_margin'], $GLOBALS['pdf_top_margin'], $GLOBALS['pdf_right_margin'], $GLOBALS['pdf_bottom_margin']), $_SESSION['language_direction'] == 'rtl' ? true : false);
        ob_start();
        echo readfile($file_to_send, "r");
        //this file contains the HTML to be converted to pdf.
        //echo $file;
        $content = ob_get_clean();
        // Fix a nasty html2pdf bug - it ignores document root!
        global $web_root, $webserver_root;
        $i = 0;
        $wrlen = strlen($web_root);
        $wsrlen = strlen($webserver_root);
        while (true) {
            $i = stripos($content, " src='/", $i + 1);
            if ($i === false) {
                break;
            }
            if (substr($content, $i + 6, $wrlen) === $web_root && substr($content, $i + 6, $wsrlen) !== $webserver_root) {
                $content = substr($content, 0, $i + 6) . $webserver_root . substr($content, $i + 6 + $wrlen);
            }
        }
        $pdf2->WriteHTML($content);
        $temp_filename = $STMT_TEMP_FILE_PDF;
        $content_pdf = $pdf2->Output($STMT_TEMP_FILE_PDF, 'F');
    } else {
        $pdf = new Cezpdf('LETTER');
        //pdf creation starts
        $pdf->ezSetMargins(45, 9, 36, 10);
        $pdf->selectFont('Courier');
        $pdf->ezSetY($pdf->ez['pageHeight'] - $pdf->ez['topMargin']);
        $countline = 1;
        $file = fopen($file_to_send, "r");
        //this file contains the text to be converted to pdf.
        while (!feof($file)) {
            $OneLine = fgets($file);
            //one line is read
            if (stristr($OneLine, "\f") == true && !feof($file)) {
                $pdf->ezNewPage();
                $pdf->ezSetY($pdf->ez['pageHeight'] - $pdf->ez['topMargin']);
                str_replace("\f", "", $OneLine);
            }
            if (stristr($OneLine, 'REMIT TO') == true || stristr($OneLine, 'Visit Date') == true || stristr($OneLine, 'Future Appointments') == true || stristr($OneLine, 'Current') == true) {
                //lines are made bold when 'REMIT TO' or 'Visit Date' is there.
                $pdf->ezText('<b>' . $OneLine . '</b>', 12, array('justification' => 'left', 'leading' => 6));
            } else {
                $pdf->ezText($OneLine, 12, array('justification' => 'left', 'leading' => 6));
            }
            $countline++;
        }
        $fh = @fopen($STMT_TEMP_FILE_PDF, 'w');
        //stored to a pdf file
        if ($fh) {
            fwrite($fh, $pdf->ezOutput());
            fclose($fh);
        }
    }
    header("Pragma: public");
    //this section outputs the pdf file to browser
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-Type: application/force-download");
    header("Content-Length: " . filesize($STMT_TEMP_FILE_PDF));
    header("Content-Disposition: attachment; filename=" . basename($STMT_TEMP_FILE_PDF));
    header("Content-Description: File Transfer");
    readfile($STMT_TEMP_FILE_PDF);
    // flush the content to the browser. If you don't do this, the text from the subsequent
    // output from this script will be in the file instead of sent to the browser.
    flush();
    exit;
    //added to exit from process properly in order to stop bad html code -ehrlive
    // sleep one second to ensure there's no follow-on.
    sleep(1);
}
Exemple #12
0
<?php

require_once toba_dir() . '/php/3ros/ezpdf/class.ezpdf.php';
$pdf = new Cezpdf();
$pdf->selectFont(toba_dir() . '/php/3ros/ezpdf/fonts/Helvetica.afm');
$pdf->ezText('Tabla', 14);
//-- Cuadro con datos
$opciones = array('splitRows' => 0, 'rowGap' => 1, 'showHeadings' => true, 'titleFontSize' => 9, 'fontSize' => 10, 'shadeCol' => array(0.9, 0.9, 0.9), 'outerLineThickness' => 0.7, 'innerLineThickness' => 0.7, 'xOrientation' => 'center', 'width' => 500);
$datos = array(array('col1' => 1, 'col2' => 2), array('col1' => 3, 'col2' => 4));
$pdf->ezTable($datos, array('col1' => 'Columna 1', 'col2' => 'Columna 2'), 'Titulo Tabla', $opciones);
$pdf->ezText("\nCódigo fuente", 14);
$pdf->ezText("\n" . file_get_contents(__FILE__), 10);
$tmp = $pdf->ezOutput(0);
header('Cache-Control: private');
header('Content-type: application/pdf');
header('Content-Length: ' . strlen(ltrim($tmp)));
header('Content-Disposition: attachment; filename="Archivo.pdf"');
header('Pragma: no-cache');
header('Expires: 0');
echo ltrim($tmp);
Exemple #13
0
 protected function crear_pdf()
 {
     toba::logger()->debug("Mensajes PDF: " . $this->pdf->messages);
     $this->temp_salida = $this->pdf->ezOutput(0);
 }
Exemple #14
0
            $pdf->ezText("\nAll hours as of " . $date->format($df), 8);
        } else {
            $sdate = new w2p_Utilities_Date($log_start_date);
            $edate = new w2p_Utilities_Date($log_end_date);
            $pdf->ezText("\nHours from " . $sdate->format($df) . ' to ' . $edate->format($df), 8);
        }
        $pdf->selectFont($font_dir . '/Helvetica-Bold.afm');
        $pdf->ezText("\n" . $AppUI->_('Overall Report'), 12);
        foreach ($allpdfdata as $company => $data) {
            $title = $company;
            $options = array('showLines' => 1, 'showHeadings' => 0, 'fontSize' => 8, 'rowGap' => 2, 'colGap' => 5, 'xPos' => 50, 'xOrientation' => 'right', 'width' => '500', 'cols' => array(0 => array('justification' => 'left', 'width' => 250), 1 => array('justification' => 'right', 'width' => 120)));
            $pdf->ezTable($data, null, $title, $options);
        }
        $w2pReport = new CReport();
        if ($fp = fopen($temp_dir . '/' . $w2pReport->getFilename() . '.pdf', 'wb')) {
            fwrite($fp, $pdf->ezOutput());
            fclose($fp);
            echo '<a href="' . W2P_BASE_URL . '/files/temp/' . $w2pReport->getFilename() . '.pdf" target="pdf">';
            echo $AppUI->_('View PDF File');
            echo '</a>';
        } else {
            echo 'Could not open file to save PDF.  ';
            if (!is_writable($temp_dir)) {
                'The files/temp directory is not writable.  Check your file system permissions.';
            }
        }
    }
    echo '</td>
</tr>
</table>';
}
                $pdf->polygon($rpoints, 8, 1);
                $color = get_text_color($person["SECONDARY_COLOR"]);
                $pdf->setcolor($color[0], $color[1], $color[2]);
                $role2Width = $pdf->getTextWidth(12, $person["SECONDARY_ROLE"]);
                $pdf->addText($right_edge - $base_width / 2 - $role2Width, $bottom_edge + 6, 12, $person["SECONDARY_ROLE"]);
                $pdf->setcolor(0, 0, 0);
            }
        }
        if ($offsetRow == 0) {
            $offsetRow = 2;
            $pageCount++;
        } else {
            $offsetRow--;
        }
    }
    $buf = $pdf->ezOutput();
    $len = strlen($buf);
    $date = date("Ymd_His");
    header("Content-type: application/pdf");
    header("Content-Length: {$len}");
    header("Content-Disposition: inline; filename=sakaiBadge{$date}.pdf");
    print $buf;
}
function get_color($hex_string = "999999")
{
    $color[0] = hexdec(substr($hex_string, 0, 2)) / 255;
    $color[1] = hexdec(substr($hex_string, 2, 2)) / 255;
    $color[2] = hexdec(substr($hex_string, 4, 2)) / 255;
    return $color;
}
function get_text_color($hex_string = "999999")
$pdf->ezText("\n\n\n ", 6, $estilo1);
$pdf->ezTable($data, '', '', array('fontSize' => 6, 'width' => 700));
//Var para almacenar la hora con formato
$hora = date("H") . "_" . date("i") . "_" . date("s");
// var que almacena el dia de la fecha
$ddate = date('d');
// var que almacena el mes de la fecha
$mdate = date('m');
// var que almacena el año de la fecha
$adate = date('Y');
// var que almacena  la fecha formateada
$fecha = $adate . "_" . $mdate . "_" . $ddate;
//guarda el path del archivo generado
$archivo = "{$ruta_raiz}/bodega/masiva/tmp_{$usua_doc}" . "_{$fecha}" . "_{$hora}.pdf";
//Referencia el PDF a generar
$pdfcode = $pdf->ezOutput();
$fp = fopen($archivo, 'wb');
fwrite($fp, $pdfcode);
fclose($fp);
?>
                	 	
	
<head>
<title>Untitled Document</title>
<link rel="stylesheet" href="../estilos/orfeo.css">
</head>
<script>
function enviar(argumento) {

	document.formMensaje.action="./masiva/"+argumento+"?"+document.formMensaje.params.value;
	document.formMensaje.submit();
 function ezOutput($debug = false, $template)
 {
     if ($debug) {
         return $this->_save;
     }
     $this->setupTOC();
     if ($template) {
         uksort($this->indexContents, 'strnatcasecmp');
         $xpos = 520;
         $z = 0;
         foreach ($this->indexContents as $letter => $contents) {
             if ($z++ / 50 == 0) {
                 phpDocumentor_out('.');
                 flush();
             }
             uksort($this->indexContents[$letter], array($this, 'mystrnatcasecmp'));
         }
         $template->assign('indexcontents', $this->indexContents);
         $this->ezText($template->fetch('index.tpl'));
         $this->setupTOC();
     }
     return parent::ezOutput();
 }
 function _print_prescription_old($p, &$toFile)
 {
     $pdf = new Cezpdf($GLOBALS['rx_paper_size']);
     $pdf->ezSetMargins($GLOBALS['rx_top_margin'], $GLOBALS['rx_bottom_margin'], $GLOBALS['rx_left_margin'], $GLOBALS['rx_right_margin']);
     $pdf->selectFont('Helvetica');
     if (!empty($this->pconfig['logo'])) {
         $pdf->ezImage($this->pconfig['logo'], "", "", "none", "left");
     }
     $pdf->ezText($p->get_prescription_display(), 10);
     if ($this->pconfig['use_signature']) {
         $pdf->ezImage($this->pconfig['signature'], "", "", "none", "left");
     } else {
         $pdf->ezText("\n\n\n\nSignature:________________________________", 10);
     }
     if (!empty($toFile)) {
         $toFile = $pdf->ezOutput();
     } else {
         $pdf->ezStream();
         // $pdf->ezStream(array('compress' => 0)); // for testing with uncompressed output
     }
     return;
 }