%PDF- %PDF-
| Direktori : /home/tjamichg/intranet.tjamich.gob.mx/intranet/pdf/ |
| Current File : /home/tjamichg/intranet.tjamich.gob.mx/intranet/pdf/flowing_blockv5.php |
<?php
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);
//FUNCION FECHA A TEXTO
//FUNCION FECHA A TEXTO
//FUNCION FECHA A TEXTO
//FUNCION FECHA A TEXTO
//FUNCION FECHA A TEXTO
/*------------------------------------------------------------------
* hug0
* Blog Kiuvox
* funcion para generar la fecha en letras
* http://blog.kiuvox.com
* ----------------------------------------------------------------
*/
function fechaATexto($fecha){
$fecha_separada=explode("-", $fecha);
$dia= strtolower(numtoletras($fecha_separada[0]));
switch ($fecha_separada[1]) {
case "01":
$mes="ENERO";
break;
case "02":
$mes="FEBRERO";
break;
case "03":
$mes="MARZO";
break;
case "04":
$mes="ABRIL";
break;
case "05":
$mes="MAYO";
break;
case "06":
$mes="JUNIO";
break;
case "07":
$mes="JULIO";
break;
case "08":
$mes="AGOSTO";
break;
case "09":
$mes="SEPTIEMBRE";
break;
case "10":
$mes="OCTUBRE";
break;
case "11":
$mes="NOVIEMBRE";
break;
case "12":
$mes="DICIEMBRE";
break;
default:
break;
}
$anio= strtolower(numtoletras($fecha_separada[2]));
return "$dia DE $mes DEL $anio.";
}
//FUNCION DIA A POSICIÓN
//FUNCION DIA A POSICIÓN
//FUNCION DIA A POSICIÓN
//FUNCION DIA A POSICIÓN
//FUNCION DIA A POSICIÓN
function convertirdia($numero)
{
$valor = array('primero', 'segundo', 'tercero', 'cuarto', 'quinto', 'sexto', 'séptimo', 'octavo', 'noveno', 'décimo', 'undécimo', 'duodécimo', 'decimotercero', 'decimocuarto', 'decimoquinto ', 'decimosexto', 'decimoséptimo ', 'decimoctavo', 'decimonoveno', 'vigésimo', 'vigésimo primero', 'vigésimo segundo', 'vigésimo tercero', 'vigésimo cuarto', 'vigésimo quinto', 'vigésimo sexto', 'vigésimo séptimo', 'vigésimo octavo', 'vigésimo noveno', 'trigésimo', 'trigésimo primero');
return $valor[$numero - 1];
}
//FUNCION MES A TEXTO
//FUNCION MES A TEXTO
//FUNCION MES A TEXTO
//FUNCION MES A TEXTO
//FUNCION MES A TEXTO
function mesATexto($fecha){
switch ($fecha) {
case "01":
$mes="ENERO";
break;
case "02":
$mes="FEBRERO";
break;
case "03":
$mes="MARZO";
break;
case "04":
$mes="ABRIL";
break;
case "05":
$mes="MAYO";
break;
case "06":
$mes="JUNIO";
break;
case "07":
$mes="JULIO";
break;
case "08":
$mes="AGOSTO";
break;
case "09":
$mes="SEPTIEMBRE";
break;
case "10":
$mes="OCTUBRE";
break;
case "11":
$mes="NOVIEMBRE";
break;
case "12":
$mes="DICIEMBRE";
break;
default:
break;
}
return "$mes";
}
//FUNCION NUMERO A TEXTO
//FUNCION NUMERO A TEXTO
//FUNCION NUMERO A TEXTO
//FUNCION NUMERO A TEXTO
//FUNCION NUMERO A TEXTO
//------ Máxima cifra soportada: 18 dígitos con 2 decimales
//------ 999,999,999,999,999,999.99
// NOVECIENTOS NOVENTA Y NUEVE MIL NOVECIENTOS NOVENTA Y NUEVE BILLONES
// NOVECIENTOS NOVENTA Y NUEVE MIL NOVECIENTOS NOVENTA Y NUEVE MILLONES
// NOVECIENTOS NOVENTA Y NUEVE MIL NOVECIENTOS NOVENTA Y NUEVE PESOS 99/100 M.N.
//------ Creada por: ---------------
//------ ULTIMINIO RAMOS GALÁN ---------------
//------ uramos@gmail.com ---------------
//------ 10 de junio de 2009. México, D.F. ---------------
//------ PHP Version 4.3.1 o mayores (aunque podría funcionar en versiones anteriores, tendrías que probar)
function numtoletras($xcifra)
{
$xarray = array(0 => "Cero",
1 => "UNO", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", "SIETE", "OCHO", "NUEVE",
"DIEZ", "ONCE", "DOCE", "TRECE", "CATORCE", "QUINCE", "DIECISEIS", "DIECISIETE", "DIECIOCHO", "DIECINUEVE",
"VEINTI", 30 => "TREINTA", 40 => "CUARENTA", 50 => "CINCUENTA", 60 => "SESENTA", 70 => "SETENTA", 80 => "OCHENTA", 90 => "NOVENTA",
100 => "CIENTO", 200 => "DOSCIENTOS", 300 => "TRESCIENTOS", 400 => "CUATROCIENTOS", 500 => "QUINIENTOS", 600 => "SEISCIENTOS", 700 => "SETECIENTOS", 800 => "OCHOCIENTOS", 900 => "NOVECIENTOS"
);
//
$xcifra = trim($xcifra);
$xlength = strlen($xcifra);
$xpos_punto = strpos($xcifra, ".");
$xaux_int = $xcifra;
$xdecimales = "00";
if (!($xpos_punto === false)) {
if ($xpos_punto == 0) {
$xcifra = "0" . $xcifra;
$xpos_punto = strpos($xcifra, ".");
}
$xaux_int = substr($xcifra, 0, $xpos_punto); // obtengo el entero de la cifra a covertir
$xdecimales = substr($xcifra . "00", $xpos_punto + 1, 2); // obtengo los valores decimales
}
$XAUX = str_pad($xaux_int, 18, " ", STR_PAD_LEFT); // ajusto la longitud de la cifra, para que sea divisible por centenas de miles (grupos de 6)
$xcadena = "";
for ($xz = 0; $xz < 3; $xz++) {
$xaux = substr($XAUX, $xz * 6, 6);
$xi = 0;
$xlimite = 6; // inicializo el contador de centenas xi y establezco el límite a 6 dígitos en la parte entera
$xexit = true; // bandera para controlar el ciclo del While
while ($xexit) {
if ($xi == $xlimite) { // si ya llegó al límite máximo de enteros
break; // termina el ciclo
}
$x3digitos = ($xlimite - $xi) * -1; // comienzo con los tres primeros digitos de la cifra, comenzando por la izquierda
$xaux = substr($xaux, $x3digitos, abs($x3digitos)); // obtengo la centena (los tres dígitos)
for ($xy = 1; $xy < 4; $xy++) { // ciclo para revisar centenas, decenas y unidades, en ese orden
switch ($xy) {
case 1: // checa las centenas
if (substr($xaux, 0, 3) < 100) { // si el grupo de tres dígitos es menor a una centena ( < 99) no hace nada y pasa a revisar las decenas
} else {
$key = (int) substr($xaux, 0, 3);
if (TRUE === array_key_exists($key, $xarray)){ // busco si la centena es número redondo (100, 200, 300, 400, etc..)
$xseek = $xarray[$key];
$xsub = subfijo($xaux); // devuelve el subfijo correspondiente (Millón, Millones, Mil o nada)
if (substr($xaux, 0, 3) == 100)
$xcadena = " " . $xcadena . " CIEN " . $xsub;
else
$xcadena = " " . $xcadena . " " . $xseek . " " . $xsub;
$xy = 3; // la centena fue redonda, entonces termino el ciclo del for y ya no reviso decenas ni unidades
}
else { // entra aquí si la centena no fue numero redondo (101, 253, 120, 980, etc.)
$key = (int) substr($xaux, 0, 1) * 100;
$xseek = $xarray[$key]; // toma el primer caracter de la centena y lo multiplica por cien y lo busca en el arreglo (para que busque 100,200,300, etc)
$xcadena = " " . $xcadena . " " . $xseek;
} // ENDIF ($xseek)
} // ENDIF (substr($xaux, 0, 3) < 100)
break;
case 2: // checa las decenas (con la misma lógica que las centenas)
if (substr($xaux, 1, 2) < 10) {
} else {
$key = (int) substr($xaux, 1, 2);
if (TRUE === array_key_exists($key, $xarray)) {
$xseek = $xarray[$key];
$xsub = subfijo($xaux);
if (substr($xaux, 1, 2) == 20)
$xcadena = " " . $xcadena . " VEINTE " . $xsub;
else
$xcadena = " " . $xcadena . " " . $xseek . " " . $xsub;
$xy = 3;
}
else {
$key = (int) substr($xaux, 1, 1) * 10;
$xseek = $xarray[$key];
if (20 == substr($xaux, 1, 1) * 10)
$xcadena = " " . $xcadena . " " . $xseek;
else
$xcadena = " " . $xcadena . " " . $xseek . " Y ";
} // ENDIF ($xseek)
} // ENDIF (substr($xaux, 1, 2) < 10)
break;
case 3: // checa las unidades
if (substr($xaux, 2, 1) < 1) { // si la unidad es cero, ya no hace nada
} else {
$key = (int) substr($xaux, 2, 1);
$xseek = $xarray[$key]; // obtengo directamente el valor de la unidad (del uno al nueve)
$xsub = subfijo($xaux);
$xcadena = " " . $xcadena . " " . $xseek . " " . $xsub;
} // ENDIF (substr($xaux, 2, 1) < 1)
break;
} // END SWITCH
} // END FOR
$xi = $xi + 3;
} // ENDDO
if (substr(trim($xcadena), -5, 5) == "ILLON") // si la cadena obtenida termina en MILLON o BILLON, entonces le agrega al final la conjuncion DE
$xcadena.= " DE";
if (substr(trim($xcadena), -7, 7) == "ILLONES") // si la cadena obtenida en MILLONES o BILLONES, entoncea le agrega al final la conjuncion DE
$xcadena.= " DE";
// ----------- esta línea la puedes cambiar de acuerdo a tus necesidades o a tu país -------
if (trim($xaux) != "") {
switch ($xz) {
case 0:
if (trim(substr($XAUX, $xz * 6, 6)) == "1")
$xcadena.= "UN BILLON ";
else
$xcadena.= " BILLONES ";
break;
case 1:
if (trim(substr($XAUX, $xz * 6, 6)) == "1")
$xcadena.= "UN MILLON ";
else
$xcadena.= " MILLONES ";
break;
case 2:
if ($xcifra < 1) {
//$xcadena = "CERO PESOS $xdecimales/100 M.N.";
}
if ($xcifra >= 1 && $xcifra < 2) {
//$xcadena = "UN PESO $xdecimales/100 M.N. ";
}
if ($xcifra >= 2) {
//$xcadena.= " PESOS $xdecimales/100 M.N. "; //
}
break;
} // endswitch ($xz)
} // ENDIF (trim($xaux) != "")
// ------------------ en este caso, para México se usa esta leyenda ----------------
$xcadena = str_replace("VEINTI ", "VEINTI", $xcadena); // quito el espacio para el VEINTI, para que quede: VEINTICUATRO, VEINTIUN, VEINTIDOS, etc
$xcadena = str_replace(" ", " ", $xcadena); // quito espacios dobles
$xcadena = str_replace("UN UN", "UN", $xcadena); // quito la duplicidad
$xcadena = str_replace(" ", " ", $xcadena); // quito espacios dobles
$xcadena = str_replace("BILLON DE MILLONES", "BILLON DE", $xcadena); // corrigo la leyenda
$xcadena = str_replace("BILLONES DE MILLONES", "BILLONES DE", $xcadena); // corrigo la leyenda
$xcadena = str_replace("DE UN", "UN", $xcadena); // corrigo la leyenda
$xcadena = str_replace("DIECISEIS", "DIECISÉIS", $xcadena); // corrigo la leyenda
$xcadena = str_replace("VEINTIUN", "VEINTIÚN", $xcadena); // corrigo la leyenda
$xcadena = str_replace("VEINTISEIS", "VEINTISÉIS", $xcadena); // corrigo la leyenda
} // ENDFOR ($xz)
return trim($xcadena);
}
// END FUNCTION
function subfijo($xx)
{ // esta función regresa un subfijo para la cifra
$xx = trim($xx);
$xstrlen = strlen($xx);
if ($xstrlen == 1 || $xstrlen == 2 || $xstrlen == 3)
$xsub = "";
//
if ($xstrlen == 4 || $xstrlen == 5 || $xstrlen == 6)
$xsub = "MIL";
//
return $xsub;
}
// END FUNCTION
// REQUIRED Y FUNCIONES HEXADECIMALES
// REQUIRED Y FUNCIONES HEXADECIMALES
// REQUIRED Y FUNCIONES HEXADECIMALES
// REQUIRED Y FUNCIONES HEXADECIMALES
// REQUIRED Y FUNCIONES HEXADECIMALES
// REQUIRED Y FUNCIONES HEXADECIMALES
require 'fpdf/fpdf.php';
//function hex2dec
//returns an associative array (keys: R,G,B) from
//a hex html code (e.g. #3FE5AA)
function hex2dec($couleur = "#000000"){
$R = substr($couleur, 1, 2);
$rouge = hexdec($R);
$V = substr($couleur, 3, 2);
$vert = hexdec($V);
$B = substr($couleur, 5, 2);
$bleu = hexdec($B);
$tbl_couleur = array();
$tbl_couleur['R']=$rouge;
$tbl_couleur['V']=$vert;
$tbl_couleur['B']=$bleu;
return $tbl_couleur;
}
//conversion pixel -> millimeter at 72 dpi
function px2mm($px){
return $px*25.4/72;
}
function txtentities($html){
$trans = get_html_translation_table(HTML_ENTITIES);
$trans = array_flip($trans);
return strtr($html, $trans);
}
// FUNCIONES PARA BLOQUES FLOTANTES
// FUNCIONES PARA BLOQUES FLOTANTES
// FUNCIONES PARA BLOQUES FLOTANTES
// FUNCIONES PARA BLOQUES FLOTANTES
// FUNCIONES PARA BLOQUES FLOTANTES
// FUNCIONES PARA BLOQUES FLOTANTES
class PDF_FlowingBlock extends FPDF
{
//FFFUNCIONES DE CELDA FLOTANTE
//FFFUNCIONES DE CELDA FLOTANTE
//FFFUNCIONES DE CELDA FLOTANTE
//FFFUNCIONES DE CELDA FLOTANTE
//FFFUNCIONES DE CELDA FLOTANTE
// NOTA: SOLO PUEDEN ESTAR COLOCADAS A LA IZQUIERDA
var $flowingBlockAttr;
function saveFont()
{
$saved = array();
$saved['family'] = $this->FontFamily;
$saved['style'] = $this->FontStyle;
$saved['sizePt'] = $this->FontSizePt;
$saved['size'] = $this->FontSize;
$saved['curr'] = &$this->CurrentFont;
return $saved;
}
function restoreFont($saved)
{
$this->FontFamily = $saved['family'];
$this->FontStyle = $saved['style'];
$this->FontSizePt = $saved['sizePt'];
$this->FontSize = $saved['size'];
$this->CurrentFont = &$saved['curr'];
if ($this->page > 0)
$this->_out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt));
}
function newFlowingBlock($w, $h, $b = 0, $a = 'J', $f = 0)
{
// cell width in points
$this->flowingBlockAttr['width'] = $w * $this->k;
// line height in user units
$this->flowingBlockAttr['height'] = $h;
$this->flowingBlockAttr['lineCount'] = 0;
$this->flowingBlockAttr['border'] = $b;
$this->flowingBlockAttr['align'] = $a;
$this->flowingBlockAttr['fill'] = $f;
$this->flowingBlockAttr['font'] = array();
$this->flowingBlockAttr['content'] = array();
$this->flowingBlockAttr['contentWidth'] = 0;
}
function finishFlowingBlock()
{
$maxWidth = &$this->flowingBlockAttr['width'];
$lineHeight = &$this->flowingBlockAttr['height'];
$border = &$this->flowingBlockAttr['border'];
$align = &$this->flowingBlockAttr['align'];
$fill = &$this->flowingBlockAttr['fill'];
$content = &$this->flowingBlockAttr['content'];
$font = &$this->flowingBlockAttr['font'];
// set normal spacing
$this->_out(sprintf('%.3F Tw', 0));
// print out each chunk
// the amount of space taken up so far in user units
$usedWidth = 0;
foreach ($content as $k => $chunk) {
$b = '';
if (is_int(strpos($border, 'B')))
$b .= 'B';
if ($k == 0 && is_int(strpos($border, 'L')))
$b .= 'L';
if ($k == count($content) - 1 && is_int(strpos($border, 'R')))
$b .= 'R';
$this->restoreFont($font[$k]);
// if it's the last chunk of this line, move to the next line after
if ($k == count($content) - 1)
$this->Cell(($maxWidth / $this->k) - $usedWidth + 2 * $this->cMargin, $lineHeight, $chunk, $b, 1, $align, $fill);
else
$this->Cell($this->GetStringWidth($chunk), $lineHeight, $chunk, $b, 0, $align, $fill);
$usedWidth += $this->GetStringWidth($chunk);
}
}
function WriteFlowingBlock($s)
{
// width of all the content so far in points
$contentWidth = &$this->flowingBlockAttr['contentWidth'];
// cell width in points
$maxWidth = &$this->flowingBlockAttr['width'];
$lineCount = &$this->flowingBlockAttr['lineCount'];
// line height in user units
$lineHeight = &$this->flowingBlockAttr['height'];
$border = &$this->flowingBlockAttr['border'];
$align = &$this->flowingBlockAttr['align'];
$fill = &$this->flowingBlockAttr['fill'];
$content = &$this->flowingBlockAttr['content'];
$font = &$this->flowingBlockAttr['font'];
$font[] = $this->saveFont();
$content[] = '';
$currContent = &$content[count($content) - 1];
// where the line should be cutoff if it is to be justified
$cutoffWidth = $contentWidth;
// for every character in the string
for ($i = 0; $i < strlen($s); $i++) {
// extract the current character
$c = $s[$i];
// get the width of the character in points
$cw = $this->CurrentFont['cw'][$c] * ($this->FontSizePt / 1000);
if ($c == ' ') {
$currContent .= ' ';
$cutoffWidth = $contentWidth;
$contentWidth += $cw;
continue;
}
// try adding another char
if ($contentWidth + $cw > $maxWidth) {
// won't fit, output what we have
$lineCount++;
// contains any content that didn't make it into this print
$savedContent = '';
$savedFont = array();
// first, cut off and save any partial words at the end of the string
$words = explode(' ', $currContent);
// if it looks like we didn't finish any words for this chunk
if (count($words) == 1) {
// save and crop off the content currently on the stack
$savedContent = array_pop($content);
$savedFont = array_pop($font);
// trim any trailing spaces off the last bit of content
$currContent = &$content[count($content) - 1];
$currContent = rtrim($currContent);
}
// otherwise, we need to find which bit to cut off
else {
$lastContent = '';
for ($w = 0; $w < count($words) - 1; $w++)
$lastContent .= "{$words[$w]} ";
$savedContent = $words[count($words) - 1];
$savedFont = $this->saveFont();
// replace the current content with the cropped version
$currContent = rtrim($lastContent);
}
// update $contentWidth and $cutoffWidth since they changed with cropping
$contentWidth = 0;
foreach ($content as $k => $chunk) {
$this->restoreFont($font[$k]);
$contentWidth += $this->GetStringWidth($chunk) * $this->k;
}
$cutoffWidth = $contentWidth;
// if it's justified, we need to find the char spacing
if ($align == 'J') {
// count how many spaces there are in the entire content string
$numSpaces = 0;
foreach ($content as $chunk)
$numSpaces += substr_count($chunk, ' ');
// if there's more than one space, find word spacing in points
if ($numSpaces > 0)
$this->ws = ($maxWidth - $cutoffWidth) / $numSpaces;
else
$this->ws = 0;
$this->_out(sprintf('%.3F Tw', $this->ws));
}
// otherwise, we want normal spacing
else
$this->_out(sprintf('%.3F Tw', 0));
// print out each chunk
$usedWidth = 0;
foreach ($content as $k => $chunk) {
$this->restoreFont($font[$k]);
$stringWidth = $this->GetStringWidth($chunk) + ($this->ws * substr_count($chunk, ' ') / $this->k);
// determine which borders should be used
$b = '';
if ($lineCount == 1 && is_int(strpos($border, 'T')))
$b .= 'T';
if ($k == 0 && is_int(strpos($border, 'L')))
$b .= 'L';
if ($k == count($content) - 1 && is_int(strpos($border, 'R')))
$b .= 'R';
// if it's the last chunk of this line, move to the next line after
if ($k == count($content) - 1)
$this->Cell(($maxWidth / $this->k) - $usedWidth + 2 * $this->cMargin, $lineHeight, $chunk, $b, 1, $align, $fill);
else {
$this->Cell($stringWidth + 2 * $this->cMargin, $lineHeight, $chunk, $b, 0, $align, $fill);
$this->x -= 2 * $this->cMargin;
}
$usedWidth += $stringWidth;
}
// move on to the next line, reset variables, tack on saved content and current char
$this->restoreFont($savedFont);
$font = array($savedFont);
$content = array($savedContent . $s[$i]);
$currContent = &$content[0];
$contentWidth = $this->GetStringWidth($currContent) * $this->k;
$cutoffWidth = $contentWidth;
}
// another character will fit, so add it on
else {
$contentWidth += $cw;
$currContent .= $s[$i];
}
}
}
//FFFUNCIONES DE WRITE-HTML
//FFFUNCIONES DE WRITE-HTML
//FFFUNCIONES DE WRITE-HTML
//FFFUNCIONES DE WRITE-HTML
//FFFUNCIONES DE WRITE-HTML
var $B;
var $I;
var $U;
var $HREF;
var $fontlist;
var $issetfont;
var $issetcolor;
function __construct($orientation = 'P', $unit = 'mm', $format = 'A4')
{
//Call parent constructor
parent::__construct($orientation, $unit, $format);
//Initialization
$this->B = 0;
$this->I = 0;
$this->U = 0;
$this->HREF = '';
$this->fontlist = array('arial', 'times', 'courier', 'helvetica', 'symbol');
$this->issetfont = false;
$this->issetcolor = false;
}
// Esta WirteHTML hasta justo antes de Justify permite cargar texto en html para cargar estilos de texto y otras funciones
function WriteHTML($html)
{
//HTML parser
$html = strip_tags($html, "<b><u><i><a><img><p><br><strong><em><font><tr><blockquote>"); //supprime tous les tags sauf ceux reconnus
$html = str_replace("\n", ' ', $html); //remplace retour à la ligne par un espace
$a = preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE); //éclate la chaîne avec les balises
foreach ($a as $i => $e) {
if ($i % 2 == 0) {
//Text
if ($this->HREF)
$this->PutLink($this->HREF, $e);
else
$this->Write(5, stripslashes(txtentities($e)));
} else {
//Tag
if ($e[0] == '/')
$this->CloseTag(strtoupper(substr($e, 1)));
else {
//Extract attributes
$a2 = explode(' ', $e);
$tag = strtoupper(array_shift($a2));
$attr = array();
foreach ($a2 as $v) {
if (preg_match('/([^=]*)=["\']?([^"\']*)/', $v, $a3))
$attr[strtoupper($a3[1])] = $a3[2];
}
$this->OpenTag($tag, $attr);
}
}
}
}
function OpenTag($tag, $attr)
{
//Opening tag
switch ($tag) {
case 'STRONG':
$this->SetStyle('B', true);
break;
case 'EM':
$this->SetStyle('I', true);
break;
case 'B':
case 'I':
case 'U':
$this->SetStyle($tag, true);
break;
case 'A':
$this->HREF = $attr['HREF'];
break;
case 'IMG':
if (isset($attr['SRC']) && (isset($attr['WIDTH']) || isset($attr['HEIGHT']))) {
if (!isset($attr['WIDTH']))
$attr['WIDTH'] = 0;
if (!isset($attr['HEIGHT']))
$attr['HEIGHT'] = 0;
$this->Image($attr['SRC'], $this->GetX(), $this->GetY(), px2mm($attr['WIDTH']), px2mm($attr['HEIGHT']));
}
break;
case 'TR':
case 'BLOCKQUOTE':
case 'BR':
$this->Ln(5);
break;
case 'P':
$this->Ln(10);
break;
case 'FONT':
if (isset($attr['COLOR']) && $attr['COLOR'] != '') {
$coul = hex2dec($attr['COLOR']);
$this->SetTextColor($coul['R'], $coul['V'], $coul['B']);
$this->issetcolor = true;
}
if (isset($attr['FACE']) && in_array(strtolower($attr['FACE']), $this->fontlist)) {
$this->SetFont(strtolower($attr['FACE']));
$this->issetfont = true;
}
break;
}
}
function CloseTag($tag)
{
//Closing tag
if ($tag == 'STRONG')
$tag = 'B';
if ($tag == 'EM')
$tag = 'I';
if ($tag == 'B' || $tag == 'I' || $tag == 'U')
$this->SetStyle($tag, false);
if ($tag == 'A')
$this->HREF = '';
if ($tag == 'FONT') {
if ($this->issetcolor == true) {
$this->SetTextColor(0);
}
if ($this->issetfont) {
$this->SetFont('arial');
$this->issetfont = false;
}
}
}
// function SetStyle($tag, $enable)
// {
// //Modify style and select corresponding font
// $this->$tag += ($enable ? 1 : -1);
// $style = '';
// foreach (array('B', 'I', 'U') as $s) {
// if ($this->$s > 0)
// $style .= $s;
// }
// $this->SetFont('', $style);
// }
function PutLink($URL, $txt)
{
//Put a hyperlink
$this->SetTextColor(0, 0, 255);
$this->SetStyle('U', true);
$this->Write(5, $txt, $URL);
$this->SetStyle('U', false);
$this->SetTextColor(0);
}
//FFFUNCIÓN JUSTIFY SOLO SIN FORMATO HMTL NI ESTILOS
//FFFUNCIÓN JUSTIFY SOLO SIN FORMATO HMTL NI ESTILOS
//FFFUNCIÓN JUSTIFY SOLO SIN FORMATO HMTL NI ESTILOS
//FFFUNCIÓN JUSTIFY SOLO SIN FORMATO HMTL NI ESTILOS
//FFFUNCIÓN JUSTIFY SOLO SIN FORMATO HMTL NI ESTILOS
function Justify($text, $w, $h)
{
$tab_paragraphe = explode("\n", $text);
$nb_paragraphe = count($tab_paragraphe);
$j = 0;
while ($j<$nb_paragraphe) {
$paragraphe = $tab_paragraphe[$j];
$tab_mot = explode(' ', $paragraphe);
$nb_mot = count($tab_mot);
// Handle strings longer than paragraph width
$tab_mot2 = array();
$k = 0;
$l = 0;
while ($k<$nb_mot) {
$len_mot = strlen ($tab_mot[$k]);
if ($len_mot<($w-5) )
{
$tab_mot2[$l] = $tab_mot[$k];
$l++;
} else {
$m=0;
$chaine_lettre='';
while ($m<$len_mot) {
$lettre = substr($tab_mot[$k], $m, 1);
$len_chaine_lettre = $this->GetStringWidth($chaine_lettre.$lettre);
if ($len_chaine_lettre>($w-7)) {
$tab_mot2[$l] = $chaine_lettre . '-';
$chaine_lettre = $lettre;
$l++;
} else {
$chaine_lettre .= $lettre;
}
$m++;
}
if ($chaine_lettre) {
$tab_mot2[$l] = $chaine_lettre;
$l++;
}
}
$k++;
}
// Justified lines
$nb_mot = count($tab_mot2);
$i=0;
$ligne = '';
while ($i<$nb_mot) {
$mot = $tab_mot2[$i];
$len_ligne = $this->GetStringWidth($ligne . ' ' . $mot);
if ($len_ligne>($w-5)) {
$len_ligne = $this->GetStringWidth($ligne);
$nb_carac = strlen ($ligne);
$ecart = (($w-2) - $len_ligne) / $nb_carac;
$this->_out(sprintf('BT %.3F Tc ET',$ecart*$this->k));
$this->MultiCell($w,$h,$ligne);
$ligne = $mot;
} else {
if ($ligne)
{
$ligne .= ' ' . $mot;
} else {
$ligne = $mot;
}
}
$i++;
}
// Last line
$this->_out('BT 0 Tc ET');
$this->MultiCell($w,$h,$ligne);
$j++;
}
}
//FUNCION CELL FORZAR JUSTIFICACIÓN
//FUNCION CELL FORZAR JUSTIFICACIÓN
//FUNCION CELL FORZAR JUSTIFICACIÓN
//FUNCION CELL FORZAR JUSTIFICACIÓN
//FUNCION CELL FORZAR JUSTIFICACIÓN
function Cell($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '')
{
$k = $this->k;
if ($this->y + $h > $this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) {
$x = $this->x;
$ws = $this->ws;
if ($ws > 0) {
$this->ws = 0;
$this->_out('0 Tw');
}
$this->AddPage($this->CurOrientation);
$this->x = $x;
if ($ws > 0) {
$this->ws = $ws;
$this->_out(sprintf('%.3F Tw', $ws * $k));
}
}
if ($w == 0)
$w = $this->w - $this->rMargin - $this->x;
$s = '';
if ($fill || $border == 1) {
if ($fill)
$op = ($border == 1) ? 'B' : 'f';
else
$op = 'S';
$s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op);
}
if (is_string($border)) {
$x = $this->x;
$y = $this->y;
if (is_int(strpos($border, 'L')))
$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k);
if (is_int(strpos($border, 'T')))
$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k);
if (is_int(strpos($border, 'R')))
$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
if (is_int(strpos($border, 'B')))
$s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k);
}
if ($txt != '') {
if ($align == 'R')
$dx = $w - $this->cMargin - $this->GetStringWidth($txt);
elseif ($align == 'C')
$dx = ($w - $this->GetStringWidth($txt)) / 2;
elseif ($align == 'FJ') {
//Set word spacing
$wmax = ($w - 2 * $this->cMargin);
$this->ws = ($wmax - $this->GetStringWidth($txt)) / substr_count($txt, ' ');
$this->_out(sprintf('%.3F Tw', $this->ws * $this->k));
$dx = $this->cMargin;
} else
$dx = $this->cMargin;
$txt = str_replace(')', '\\)', str_replace('(', '\\(', str_replace('\\', '\\\\', $txt)));
if ($this->ColorFlag)
$s .= 'q ' . $this->TextColor . ' ';
$s .= sprintf('BT %.2F %.2F Td (%s) Tj ET', ($this->x + $dx) * $k, ($this->h - ($this->y + .5 * $h + .3 * $this->FontSize)) * $k, $txt);
if ($this->underline)
$s .= ' ' . $this->_dounderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $txt);
if ($this->ColorFlag)
$s .= ' Q';
if ($link) {
if ($align == 'FJ')
$wlink = $wmax;
else
$wlink = $this->GetStringWidth($txt);
$this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $wlink, $this->FontSize, $link);
}
}
if ($s)
$this->_out($s);
if ($align == 'FJ') {
//Remove word spacing
$this->_out('0 Tw');
$this->ws = 0;
}
$this->lasth = $h;
if ($ln > 0) {
$this->y += $h;
if ($ln == 1)
$this->x = $this->lMargin;
} else
$this->x += $w;
}
// FUNCION FOOTER - (AUTOMATIZADO)
// FUNCION FOOTER - (AUTOMATIZADO)
// FUNCION FOOTER - (AUTOMATIZADO)
// FUNCION FOOTER - (AUTOMATIZADO)
// FUNCION FOOTER - (AUTOMATIZADO)
//USAR : $pdf->AliasNbPages(); ANTES DE : $pdf->AddPage();
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',12);
// Page number
// $this->Cell(0,10,'Pagina '.$this->PageNo().'/{nb}',0,0,'C');
$this->Cell(0,10,'MFHO/AIVN/JJHAA - '.$this->PageNo().'',0,0,'L');
}
// CABECERA AUTOMATICA CON LOGO
// CABECERA AUTOMATICA CON LOGO
// CABECERA AUTOMATICA CON LOGO
// CABECERA AUTOMATICA CON LOGO
// CABECERA AUTOMATICA CON LOGO
/*function Header()
{
// Logo
$this->Image('logo.png',10,6,30);
// Arial bold 15
$this->SetFont('Arial','B',15);
// Move to the right
$this->Cell(80);
// Title
$this->Cell(30,10,'Title',1,0,'C');
// Line break
$this->Ln(20);
}*/
//FUNCION TRANSPARENCIA DE TEXTO/IMAGEN ALPHA
//FUNCION TRANSPARENCIA DE TEXTO/IMAGEN ALPHA
//FUNCION TRANSPARENCIA DE TEXTO/IMAGEN ALPHA
//FUNCION TRANSPARENCIA DE TEXTO/IMAGEN ALPHA
//FUNCION TRANSPARENCIA DE TEXTO/IMAGEN ALPHA
protected $extgstates = array();
// alpha: real value from 0 (transparent) to 1 (opaque)
// bm: blend mode, one of the following:
// Normal, Multiply, Screen, Overlay, Darken, Lighten, ColorDodge, ColorBurn,
// HardLight, SoftLight, Difference, Exclusion, Hue, Saturation, Color, Luminosity
function SetAlpha($alpha, $bm='Normal')
{
// set alpha for stroking (CA) and non-stroking (ca) operations
$gs = $this->AddExtGState(array('ca'=>$alpha, 'CA'=>$alpha, 'BM'=>'/'.$bm));
$this->SetExtGState($gs);
}
function AddExtGState($parms)
{
$n = count($this->extgstates)+1;
$this->extgstates[$n]['parms'] = $parms;
return $n;
}
function SetExtGState($gs)
{
$this->_out(sprintf('/GS%d gs', $gs));
}
function _enddoc()
{
if(!empty($this->extgstates) && $this->PDFVersion<'1.4')
$this->PDFVersion='1.4';
parent::_enddoc();
}
function _putextgstates()
{
for ($i = 1; $i <= count($this->extgstates); $i++)
{
$this->_newobj();
$this->extgstates[$i]['n'] = $this->n;
$this->_put('<</Type /ExtGState');
$parms = $this->extgstates[$i]['parms'];
$this->_put(sprintf('/ca %.3F', $parms['ca']));
$this->_put(sprintf('/CA %.3F', $parms['CA']));
$this->_put('/BM '.$parms['BM']);
$this->_put('>>');
$this->_put('endobj');
}
}
function _putresourcedict()
{
parent::_putresourcedict();
$this->_put('/ExtGState <<');
foreach($this->extgstates as $k=>$extgstate)
$this->_put('/GS'.$k.' '.$extgstate['n'].' 0 R');
$this->_put('>>');
}
function _putresources()
{
$this->_putextgstates();
parent::_putresources();
}
// WRITETAG PARA JUSTIFICAR HTML
// WRITETAG PARA JUSTIFICAR HTML
// WRITETAG PARA JUSTIFICAR HTML
// WRITETAG PARA JUSTIFICAR HTML
// WRITETAG PARA JUSTIFICAR HTML
// WRITETAG PARA JUSTIFICAR HTML
protected $wLine; // Maximum width of the line
protected $hLine; // Height of the line
protected $Text; // Text to display
protected $border;
protected $align; // Justification of the text
protected $fill;
protected $Padding;
protected $lPadding;
protected $tPadding;
protected $bPadding;
protected $rPadding;
protected $TagStyle; // Style for each tag
protected $Indent;
protected $Bullet; // Bullet character
protected $Space; // Minimum space between words
protected $PileStyle;
protected $Line2Print; // Line to display
protected $NextLineBegin; // Buffer between lines
protected $TagName;
protected $Delta; // Maximum width minus width
protected $StringLength;
protected $LineLength;
protected $wTextLine; // Width minus paddings
protected $nbSpace; // Number of spaces in the line
protected $Xini; // Initial position
protected $href; // Current URL
protected $TagHref; // URL for a cell
protected $LastLine;
// ESTILOS PARA WRITE TAG
// (tag, tipo_letra, estilo, tamaño, color, espaciado)
// $pdf->SetStyle("h1","helvetica","B",14,"0,0,0",0);
// $pdf->SetStyle("p","helvetica","N",11,"0,0,0");
// $pdf->SetStyle("i","helvetica","I",11,"0,0,0");
// $pdf->SetStyle("em","helvetica","I",11,"0,0,0");
// $pdf->SetStyle("b","helvetica","B",11,"0,0,0");
// $pdf->SetStyle("strong","helvetica","B",11,"0,0,0");
// $pdf->SetStyle("u","helvetica","U",11,"0,0,0");
// $pdf->SetStyle("under","helvetica","U",11,"0,0,0");
// $pdf->SetStyle("li","helvetica","N",11,"0,0,0",15,'-');
// $contenidoresult = iconv('UTF-8', 'windows-1252', html_entity_decode("$contenido"));
// $pdf->WriteTag(0,5,$contenidoresult,0,"J",0,1);
// Public Functions
function WriteTag($w, $h, $txt, $border=0, $align="J", $fill=false, $padding=0)
{
$this->wLine=$w;
$this->hLine=$h;
$this->Text=trim($txt);
$this->Text=preg_replace("/\n|\r|\t/","",$this->Text);
$this->border=$border;
$this->align=$align;
$this->fill=$fill;
$this->Padding=$padding;
$this->Xini=$this->GetX();
$this->href="";
$this->PileStyle=array();
$this->TagHref=array();
$this->LastLine=false;
$this->NextLineBegin=array();
$this->SetSpace();
$this->Padding();
$this->LineLength();
$this->BorderTop();
while($this->Text!="")
{
$this->MakeLine();
$this->PrintLine();
}
$this->BorderBottom();
}
function SetStyle($tag, $family, $style, $size, $color, $indent=-1, $bullet='')
{
$tag=trim($tag);
$this->TagStyle[$tag]['family']=trim($family);
$this->TagStyle[$tag]['style']=trim($style);
$this->TagStyle[$tag]['size']=trim($size);
$this->TagStyle[$tag]['color']=trim($color);
$this->TagStyle[$tag]['indent']=$indent;
$this->TagStyle[$tag]['bullet']=$bullet;
}
// Private Functions
function SetSpace() // Minimal space between words
{
$tag=$this->Parser($this->Text);
$this->FindStyle($tag[2],0);
$this->DoStyle(0);
$this->Space=$this->GetStringWidth(" ");
}
function Padding()
{
if(preg_match("/^.+,/",$this->Padding)) {
$tab=explode(",",$this->Padding);
$this->lPadding=$tab[0];
$this->tPadding=$tab[1];
if(isset($tab[2]))
$this->bPadding=$tab[2];
else
$this->bPadding=$this->tPadding;
if(isset($tab[3]))
$this->rPadding=$tab[3];
else
$this->rPadding=$this->lPadding;
}
else
{
$this->lPadding=$this->Padding;
$this->tPadding=$this->Padding;
$this->bPadding=$this->Padding;
$this->rPadding=$this->Padding;
}
if($this->tPadding<$this->LineWidth)
$this->tPadding=$this->LineWidth;
}
function LineLength()
{
if($this->wLine==0)
$this->wLine=$this->w - $this->Xini - $this->rMargin;
$this->wTextLine = $this->wLine - $this->lPadding - $this->rPadding;
}
function BorderTop()
{
$border=0;
if($this->border==1)
$border="TLR";
$this->Cell($this->wLine,$this->tPadding,"",$border,0,'C',$this->fill);
$y=$this->GetY()+$this->tPadding;
$this->SetXY($this->Xini,$y);
}
function BorderBottom()
{
$border=0;
if($this->border==1)
$border="BLR";
$this->Cell($this->wLine,$this->bPadding,"",$border,0,'C',$this->fill);
}
function DoStyle($ind) // Applies a style
{
if(!isset($this->TagStyle[$ind]))
return;
$this->SetFont($this->TagStyle[$ind]['family'],
$this->TagStyle[$ind]['style'],
$this->TagStyle[$ind]['size']);
$tab=explode(",",$this->TagStyle[$ind]['color']);
if(count($tab)==1)
$this->SetTextColor($tab[0]);
else
$this->SetTextColor($tab[0],$tab[1],$tab[2]);
}
function FindStyle($tag, $ind) // Inheritance from parent elements
{
$tag=trim($tag);
// Family
if($this->TagStyle[$tag]['family']!="")
$family=$this->TagStyle[$tag]['family'];
else
{
foreach($this->PileStyle as $val)
{
$val=trim($val);
if($this->TagStyle[$val]['family']!="") {
$family=$this->TagStyle[$val]['family'];
break;
}
}
}
// Style
$style="";
$style1=strtoupper($this->TagStyle[$tag]['style']);
if($style1!="N")
{
$bold=false;
$italic=false;
$underline=false;
foreach($this->PileStyle as $val)
{
$val=trim($val);
$style1=strtoupper($this->TagStyle[$val]['style']);
if($style1=="N")
break;
else
{
if(strpos($style1,"B")!==false)
$bold=true;
if(strpos($style1,"I")!==false)
$italic=true;
if(strpos($style1,"U")!==false)
$underline=true;
}
}
if($bold)
$style.="B";
if($italic)
$style.="I";
if($underline)
$style.="U";
}
// Size
if($this->TagStyle[$tag]['size']!=0)
$size=$this->TagStyle[$tag]['size'];
else
{
foreach($this->PileStyle as $val)
{
$val=trim($val);
if($this->TagStyle[$val]['size']!=0) {
$size=$this->TagStyle[$val]['size'];
break;
}
}
}
// Color
if($this->TagStyle[$tag]['color']!="")
$color=$this->TagStyle[$tag]['color'];
else
{
foreach($this->PileStyle as $val)
{
$val=trim($val);
if($this->TagStyle[$val]['color']!="") {
$color=$this->TagStyle[$val]['color'];
break;
}
}
}
// Result
$this->TagStyle[$ind]['family']=$family;
$this->TagStyle[$ind]['style']=$style;
$this->TagStyle[$ind]['size']=$size;
$this->TagStyle[$ind]['color']=$color;
$this->TagStyle[$ind]['indent']=$this->TagStyle[$tag]['indent'];
}
function Parser($text)
{
$tab=array();
// Closing tag
if(preg_match("|^(</([^>]+)>)|",$text,$regs)) {
$tab[1]="c";
$tab[2]=trim($regs[2]);
}
// Opening tag
else if(preg_match("|^(<([^>]+)>)|",$text,$regs)) {
$regs[2]=preg_replace("/^a/","a ",$regs[2]);
$tab[1]="o";
$tab[2]=trim($regs[2]);
// Presence of attributes
if(preg_match("/(.+) (.+)='(.+)'/",$regs[2])) {
$tab1=preg_split("/ +/",$regs[2]);
$tab[2]=trim($tab1[0]);
foreach($tab1 as $i=>$couple)
{
if($i>0) {
$tab2=explode("=",$couple);
$tab2[0]=trim($tab2[0]);
$tab2[1]=trim($tab2[1]);
$end=strlen($tab2[1])-2;
$tab[$tab2[0]]=substr($tab2[1],1,$end);
}
}
}
}
// Space
else if(preg_match("/^( )/",$text,$regs)) {
$tab[1]="s";
$tab[2]=' ';
}
// Text
else if(preg_match("/^([^< ]+)/",$text,$regs)) {
$tab[1]="t";
$tab[2]=trim($regs[1]);
}
$begin=strlen($regs[1]);
$end=strlen($text);
$text=substr($text, $begin, $end);
$tab[0]=$text;
return $tab;
}
function MakeLine()
{
$this->Text.=" ";
$this->LineLength=array();
$this->TagHref=array();
$Length=0;
$this->nbSpace=0;
$i=$this->BeginLine();
$this->TagName=array();
if($i==0) {
$Length=$this->StringLength[0];
$this->TagName[0]=1;
$this->TagHref[0]=$this->href;
}
while($Length<$this->wTextLine)
{
$tab=$this->Parser($this->Text);
$this->Text=$tab[0];
if($this->Text=="") {
$this->LastLine=true;
break;
}
if($tab[1]=="o") {
array_unshift($this->PileStyle,$tab[2]);
$this->FindStyle($this->PileStyle[0],$i+1);
$this->DoStyle($i+1);
$this->TagName[$i+1]=1;
if($this->TagStyle[$tab[2]]['indent']!=-1) {
$Length+=$this->TagStyle[$tab[2]]['indent'];
$this->Indent=$this->TagStyle[$tab[2]]['indent'];
$this->Bullet=$this->TagStyle[$tab[2]]['bullet'];
}
if($tab[2]=="a")
$this->href=$tab['href'];
}
if($tab[1]=="c") {
array_shift($this->PileStyle);
if(isset($this->PileStyle[0]))
{
$this->FindStyle($this->PileStyle[0],$i+1);
$this->DoStyle($i+1);
}
$this->TagName[$i+1]=1;
if($this->TagStyle[$tab[2]]['indent']!=-1) {
$this->LastLine=true;
$this->Text=trim($this->Text);
break;
}
if($tab[2]=="a")
$this->href="";
}
if($tab[1]=="s") {
$i++;
$Length+=$this->Space;
$this->Line2Print[$i]="";
if($this->href!="")
$this->TagHref[$i]=$this->href;
}
if($tab[1]=="t") {
$i++;
$this->StringLength[$i]=$this->GetStringWidth($tab[2]);
$Length+=$this->StringLength[$i];
$this->LineLength[$i]=$Length;
$this->Line2Print[$i]=$tab[2];
if($this->href!="")
$this->TagHref[$i]=$this->href;
}
}
trim($this->Text);
if($Length>$this->wTextLine || $this->LastLine==true)
$this->EndLine();
}
function BeginLine()
{
$this->Line2Print=array();
$this->StringLength=array();
if(isset($this->PileStyle[0]))
{
$this->FindStyle($this->PileStyle[0],0);
$this->DoStyle(0);
}
if(count($this->NextLineBegin)>0) {
$this->Line2Print[0]=$this->NextLineBegin['text'];
$this->StringLength[0]=$this->NextLineBegin['length'];
$this->NextLineBegin=array();
$i=0;
}
else {
preg_match("/^(( *(<([^>]+)>)* *)*)(.*)/",$this->Text,$regs);
$regs[1]=str_replace(" ", "", $regs[1]);
$this->Text=$regs[1].$regs[5];
$i=-1;
}
return $i;
}
function EndLine()
{
if(end($this->Line2Print)!="" && $this->LastLine==false) {
$this->NextLineBegin['text']=array_pop($this->Line2Print);
$this->NextLineBegin['length']=end($this->StringLength);
array_pop($this->LineLength);
}
while(end($this->Line2Print)==="")
array_pop($this->Line2Print);
$this->Delta=$this->wTextLine-end($this->LineLength);
$this->nbSpace=0;
for($i=0; $i<count($this->Line2Print); $i++) {
if($this->Line2Print[$i]=="")
$this->nbSpace++;
}
}
function PrintLine()
{
$border=0;
if($this->border==1)
$border="LR";
$this->Cell($this->wLine,$this->hLine,"",$border,0,'C',$this->fill);
$y=$this->GetY();
$this->SetXY($this->Xini+$this->lPadding,$y);
if($this->Indent>0) {
if($this->Bullet!='')
$this->SetTextColor(0);
$this->Cell($this->Indent,$this->hLine,$this->Bullet);
$this->Indent=-1;
$this->Bullet='';
}
$space=$this->LineAlign();
$this->DoStyle(0);
for($i=0; $i<count($this->Line2Print); $i++)
{
if(isset($this->TagName[$i]))
$this->DoStyle($i);
if(isset($this->TagHref[$i]))
$href=$this->TagHref[$i];
else
$href='';
if($this->Line2Print[$i]=="")
$this->Cell($space,$this->hLine," ",0,0,'C',false,$href);
else
$this->Cell($this->StringLength[$i],$this->hLine,$this->Line2Print[$i],0,0,'C',false,$href);
}
$this->LineBreak();
if($this->LastLine && $this->Text!="")
$this->EndParagraph();
$this->LastLine=false;
}
function LineAlign()
{
$space=$this->Space;
if($this->align=="J") {
if($this->nbSpace!=0)
$space=$this->Space + ($this->Delta/$this->nbSpace);
if($this->LastLine)
$space=$this->Space;
}
if($this->align=="R")
$this->Cell($this->Delta,$this->hLine);
if($this->align=="C")
$this->Cell($this->Delta/2,$this->hLine);
return $space;
}
function LineBreak()
{
$x=$this->Xini;
$y=$this->GetY()+$this->hLine;
$this->SetXY($x,$y);
}
function EndParagraph()
{
$border=0;
if($this->border==1)
$border="LR";
$this->Cell($this->wLine,$this->hLine/2,"",$border,0,'C',$this->fill);
$x=$this->Xini;
$y=$this->GetY()+$this->hLine/2;
$this->SetXY($x,$y);
}
}
// EXPANSIÓN PARA WRITE HTML
// EXPANSIÓN PARA WRITE HTML
// EXPANSIÓN PARA WRITE HTML
// EXPANSIÓN PARA WRITE HTML
// EXPANSIÓN PARA WRITE HTML
// function hex2dec($couleur = "#000000"){
// $R = substr($couleur, 1, 2);
// $rouge = hexdec($R);
// $V = substr($couleur, 3, 2);
// $vert = hexdec($V);
// $B = substr($couleur, 5, 2);
// $bleu = hexdec($B);
// $tbl_couleur = array();
// $tbl_couleur['R']=$rouge;
// $tbl_couleur['G']=$vert;
// $tbl_couleur['B']=$bleu;
// return $tbl_couleur;
// }
// //conversion pixel -> millimeter in 72 dpi
// function px2mm($px){
// return $px*25.4/72;
// }
// function txtentities($html){
// $trans = get_html_translation_table(HTML_ENTITIES);
// $trans = array_flip($trans);
// return strtr($html, $trans);
// }
// ////////////////////////////////////
// class PDF extends FPDF
// {
// //variables of html parser
// protected $B;
// protected $I;
// protected $U;
// protected $HREF;
// protected $fontList;
// protected $issetfont;
// protected $issetcolor;
// function __construct($orientation='P', $unit='mm', $format='A4')
// {
// //Call parent constructor
// parent::__construct($orientation,$unit,$format);
// //Initialization
// $this->B=0;
// $this->I=0;
// $this->U=0;
// $this->HREF='';
// $this->tableborder=0;
// $this->tdbegin=false;
// $this->tdwidth=0;
// $this->tdheight=0;
// $this->tdalign="L";
// $this->tdbgcolor=false;
// $this->oldx=0;
// $this->oldy=0;
// $this->fontlist=array("arial","times","courier","helvetica","symbol");
// $this->issetfont=false;
// $this->issetcolor=false;
// }
// //////////////////////////////////////
// //html parser
// function WriteHTML($html)
// {
// $html=strip_tags($html,"<b><u><i><a><img><p><br><strong><em><font><tr><blockquote><hr><td><tr><table><sup>"); //remove all unsupported tags
// $html=str_replace("\n",'',$html); //replace carriage returns with spaces
// $html=str_replace("\t",'',$html); //replace carriage returns with spaces
// $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE); //explode the string
// foreach($a as $i=>$e)
// {
// if($i%2==0)
// {
// //Text
// if($this->HREF)
// $this->PutLink($this->HREF,$e);
// elseif($this->tdbegin) {
// if(trim($e)!='' && $e!=" ") {
// $this->Cell($this->tdwidth,$this->tdheight,$e,$this->tableborder,'',$this->tdalign,$this->tdbgcolor);
// }
// elseif($e==" ") {
// $this->Cell($this->tdwidth,$this->tdheight,'',$this->tableborder,'',$this->tdalign,$this->tdbgcolor);
// }
// }
// else
// $this->Write(5,stripslashes(txtentities($e)));
// }
// else
// {
// //Tag
// if($e[0]=='/')
// $this->CloseTag(strtoupper(substr($e,1)));
// else
// {
// //Extract attributes
// $a2=explode(' ',$e);
// $tag=strtoupper(array_shift($a2));
// $attr=array();
// foreach($a2 as $v)
// {
// if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
// $attr[strtoupper($a3[1])]=$a3[2];
// }
// $this->OpenTag($tag,$attr);
// }
// }
// }
// }
// function OpenTag($tag, $attr)
// {
// //Opening tag
// switch($tag){
// case 'SUP':
// if( !empty($attr['SUP']) ) {
// //Set current font to 6pt
// $this->SetFont('','',6);
// //Start 125cm plus width of cell to the right of left margin
// //Superscript "1"
// $this->Cell(2,2,$attr['SUP'],0,0,'L');
// }
// break;
// case 'TABLE': // TABLE-BEGIN
// if( !empty($attr['BORDER']) ) $this->tableborder=$attr['BORDER'];
// else $this->tableborder=0;
// break;
// case 'TR': //TR-BEGIN
// break;
// case 'TD': // TD-BEGIN
// if( !empty($attr['WIDTH']) ) $this->tdwidth=($attr['WIDTH']/4);
// else $this->tdwidth=40; // Set to your own width if you need bigger fixed cells
// if( !empty($attr['HEIGHT']) ) $this->tdheight=($attr['HEIGHT']/6);
// else $this->tdheight=6; // Set to your own height if you need bigger fixed cells
// if( !empty($attr['ALIGN']) ) {
// $align=$attr['ALIGN'];
// if($align=='LEFT') $this->tdalign='L';
// if($align=='CENTER') $this->tdalign='C';
// if($align=='RIGHT') $this->tdalign='R';
// }
// else $this->tdalign='L'; // Set to your own
// if( !empty($attr['BGCOLOR']) ) {
// $coul=hex2dec($attr['BGCOLOR']);
// $this->SetFillColor($coul['R'],$coul['G'],$coul['B']);
// $this->tdbgcolor=true;
// }
// $this->tdbegin=true;
// break;
// case 'HR':
// if( !empty($attr['WIDTH']) )
// $Width = $attr['WIDTH'];
// else
// $Width = $this->w - $this->lMargin-$this->rMargin;
// $x = $this->GetX();
// $y = $this->GetY();
// $this->SetLineWidth(0.2);
// $this->Line($x,$y,$x+$Width,$y);
// $this->SetLineWidth(0.2);
// $this->Ln(1);
// break;
// case 'STRONG':
// $this->SetStyle('B',true);
// break;
// case 'EM':
// $this->SetStyle('I',true);
// break;
// case 'B':
// case 'I':
// case 'U':
// $this->SetStyle($tag,true);
// break;
// case 'A':
// $this->HREF=$attr['HREF'];
// break;
// case 'IMG':
// if(isset($attr['SRC']) && (isset($attr['WIDTH']) || isset($attr['HEIGHT']))) {
// if(!isset($attr['WIDTH']))
// $attr['WIDTH'] = 0;
// if(!isset($attr['HEIGHT']))
// $attr['HEIGHT'] = 0;
// $this->Image($attr['SRC'], $this->GetX(), $this->GetY(), px2mm($attr['WIDTH']), px2mm($attr['HEIGHT']));
// }
// break;
// case 'BLOCKQUOTE':
// case 'BR':
// $this->Ln(5);
// break;
// case 'P':
// $this->Ln(10);
// break;
// case 'FONT':
// if (isset($attr['COLOR']) && $attr['COLOR']!='') {
// $coul=hex2dec($attr['COLOR']);
// $this->SetTextColor($coul['R'],$coul['G'],$coul['B']);
// $this->issetcolor=true;
// }
// if (isset($attr['FACE']) && in_array(strtolower($attr['FACE']), $this->fontlist)) {
// $this->SetFont(strtolower($attr['FACE']));
// $this->issetfont=true;
// }
// if (isset($attr['FACE']) && in_array(strtolower($attr['FACE']), $this->fontlist) && isset($attr['SIZE']) && $attr['SIZE']!='') {
// $this->SetFont(strtolower($attr['FACE']),'',$attr['SIZE']);
// $this->issetfont=true;
// }
// break;
// }
// }
// function CloseTag($tag)
// {
// //Closing tag
// if($tag=='SUP') {
// }
// if($tag=='TD') { // TD-END
// $this->tdbegin=false;
// $this->tdwidth=0;
// $this->tdheight=0;
// $this->tdalign="L";
// $this->tdbgcolor=false;
// }
// if($tag=='TR') { // TR-END
// $this->Ln();
// }
// if($tag=='TABLE') { // TABLE-END
// $this->tableborder=0;
// }
// if($tag=='STRONG')
// $tag='B';
// if($tag=='EM')
// $tag='I';
// if($tag=='B' || $tag=='I' || $tag=='U')
// $this->SetStyle($tag,false);
// if($tag=='A')
// $this->HREF='';
// if($tag=='FONT'){
// if ($this->issetcolor==true) {
// $this->SetTextColor(0);
// }
// if ($this->issetfont) {
// $this->SetFont('arial');
// $this->issetfont=false;
// }
// }
// }
// function SetStyle($tag, $enable)
// {
// //Modify style and select corresponding font
// $this->$tag+=($enable ? 1 : -1);
// $style='';
// foreach(array('B','I','U') as $s) {
// if($this->$s>0)
// $style.=$s;
// }
// $this->SetFont('',$style);
// }
// function PutLink($URL, $txt)
// {
// //Put a hyperlink
// $this->SetTextColor(0,0,255);
// $this->SetStyle('U',true);
// $this->Write(5,$txt,$URL);
// $this->SetStyle('U',false);
// $this->SetTextColor(0);
// }
// }
?>