]> git.llucax.com Git - mecon/meconlib.git/commitdiff
Agrego nueva funcionalidad al paquete MECON_PDF. Ahora hay un objeto MECON_PDF_Header...
authorMartín Marrese <marrese@gmail.com>
Tue, 27 Apr 2004 17:20:01 +0000 (17:20 +0000)
committerMartín Marrese <marrese@gmail.com>
Tue, 27 Apr 2004 17:20:01 +0000 (17:20 +0000)
lib/MECON/PDF/Header.php [new file with mode: 0644]
lib/MECON/PDF/HeaderDefecto.php [new file with mode: 0644]
lib/MECON/PDF/HeaderDefecto/medidas.php [new file with mode: 0644]
lib/MECON/PDF/Marco.php
lib/MECON/PDF/Marco/medidas.php

diff --git a/lib/MECON/PDF/Header.php b/lib/MECON/PDF/Header.php
new file mode 100644 (file)
index 0000000..b9854f2
--- /dev/null
@@ -0,0 +1,58 @@
+<?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80:
+-------------------------------------------------------------------------------
+                             Ministerio de Economía
+                                    meconlib
+-------------------------------------------------------------------------------
+This file is part of meconlib.
+
+meconlib is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+
+meconlib is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+You should have received a copy of the GNU General Public License; if not,
+write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+Boston, MA  02111-1307  USA
+-------------------------------------------------------------------------------
+Creado: mar abr 27 12:25:05 ART 2004
+Autor:  Martin Marrese <mmarre@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id$
+-----------------------------------------------------------------------------*/
+
+require_once 'MECON/PDF/Contenido.php';
+
+/**
+ * Libreria de header en PDF.
+ */
+class MECON_PDF_Header extends MECON_PDF_Contenido {
+
+    /**
+     * Funcion que agrega el contenido del encabezado al PDF.
+     *
+     * @param &Object $MARCO MECON_PDF_Marco.
+     *
+     * @return void
+     * @access public
+     */
+    function toPdf(&$MARCO) {
+        trigger_error ('HAY QUE REDERIFINIR EL METODO toPDF. Vago/a!!!', 
+                E_USER_WARNING);
+    }
+
+    /**
+     * Devuelve el espacio (altura) que ocupa el encabezado.
+     *
+     * @return int
+     * @access public
+     */
+    function getAltura() {
+        trigger_error ('HAY QUE REDERIFINIR EL METODO getAltura. Vago/a!!!', 
+                E_USER_WARNING);
+    }
+}
+?>
\ No newline at end of file
diff --git a/lib/MECON/PDF/HeaderDefecto.php b/lib/MECON/PDF/HeaderDefecto.php
new file mode 100644 (file)
index 0000000..764984e
--- /dev/null
@@ -0,0 +1,250 @@
+<?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80:
+-------------------------------------------------------------------------------
+                             Ministerio de Economía
+                                    meconlib
+-------------------------------------------------------------------------------
+This file is part of meconlib.
+
+meconlib is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+
+meconlib is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+You should have received a copy of the GNU General Public License; if not,
+write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+Boston, MA  02111-1307  USA
+-------------------------------------------------------------------------------
+Creado: mar abr 27 12:25:05 ART 2004
+Autor:  Martin Marrese <mmarre@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id$
+-----------------------------------------------------------------------------*/
+
+require_once 'MECON/PDF/Header.php';
+
+/**
+ * Libreria de header por defecto en PDF.
+ */
+class MECON_PDF_HeaderDefecto extends MECON_PDF_Header {
+    /**
+     * Configuración del encabezado. Solamente lo que hace al tamaño y
+     * orientación pasados por parametro en el constructor.
+     * @var array $config
+     * @access protected
+     */
+    var $_config = null;
+
+    /**
+     * Logo.
+     * @var string $logo
+     * @access public
+     */
+    var $logo; 
+
+    /**
+     * Paginador.
+     * @var bool $paginador
+     * @access public 
+     */
+    var $paginador = true;
+
+    /**
+     * Fecha. Si es true se pone la fecha del servidor, si es false no se pone
+     * nada, en caso contrario se pone lo que haya en esta variable.
+     * @var mixed $fecha
+     * @access public
+     */
+    var $fecha = true;
+    
+    /**
+     * Seccion.
+     * @var string $seccion
+     * @access public 
+     */
+    var $seccion = '';
+
+    /**
+     * SubSeccion.
+     * @var string $subseccion
+     * @access public 
+     */
+    var $subseccion = 'Ministerio de Economia';
+        
+    /**
+     * Class Constructor.
+     *
+     * @param string $tam Tamaño de las hojas.
+     * @param string $ori Orientacion de las hojaz (portrait o landscape).
+     *
+     * @return void           
+     * @access public         
+     */
+    function MECON_PDF_HeaderDefecto($tam = "a4", $ori = "portrait") {
+        $tmp = include 'MECON/PDF/HeaderDefecto/medidas.php' ; 
+        $this->_config = $tmp[$tam][$ori]['encabezado'];
+
+        //Ver en donde poner esto
+        if (@$this->_config['logo']['path']) {
+            $this->logo = $this->_config['logo']['path'];
+        }
+    }
+
+    /**
+     * Funcion que agrega el contenido del encabezado al PDF.
+     *
+     * @param &Object $MARCO MECON_PDF_Marco.
+     *
+     * @return void
+     * @access public
+     */
+    function toPdf(&$MARCO) {
+        $this->_addLogo($MARCO);
+        $this->_addSeccion($MARCO);
+        $this->_addSubseccion($MARCO);
+        $this->_addPager($MARCO);
+        $this->_addDate($MARCO);
+        $this->_addHeaderRectangle($MARCO);
+    }
+
+    /**
+     * Devuelve el espacio (altura) que ocupa el encabezado.
+     *
+     * @return int
+     * @access public
+     */
+    function getAltura() {
+        return $this->_config['Yi'];
+    }
+
+    /**
+     * Funcion que agrega el logo al encabezado de una pagina.
+     *
+     * @param &Object $MARCO MECON_PDF_Marco.
+     *
+     * @return void
+     * @access protected
+     */
+    function _addLogo(&$MARCO) {
+        if ($this->logo) {
+            $MARCO->addImage($this->logo, $this->_config['logo']['X'],
+                    $this->_config['logo']['Y'], null, 'jpg');
+        }
+    }
+
+    /**
+     * Funcion que agrega la seccion al encabezado de una pagina.
+     *
+     * @return void
+     * @param &Object $MARCO MECON_PDF_Marco.
+     *
+     * @access protected
+     */
+    function _addSeccion(&$MARCO) {
+        if ($this->seccion) {
+            $tmp = $MARCO->strlen($this->seccion, $this->_config['seccion']);
+            $tmp2 = $this->_config['linea2']['Xi'] - $this->_config['linea1']['Xi'];
+            if ($tmp >= $tmp2) {
+                $this->seccion = $MARCO->wrapLine ($this->seccion, $tmp2,
+                        $this->_config['seccion']);
+                $tmp = $MARCO->strlen($this->seccion, $this->_config['seccion']);
+            }
+            $init = $this->_config['linea1']['Xi'] + ( $this->_config['linea2']['Xi'] 
+                    - $this->_config['linea1']['Xi'] - $tmp) / 2; 
+            $MARCO->addText($init, $this->_config['seccion']['Y'], $this->seccion,
+                    $this->_config['seccion']);
+        }
+    }
+   
+    /**
+     * Funcion que agrega la subseccion al encabezado de una pagina.
+     *
+     * @return void
+     * @param &Object $MARCO MECON_PDF_Marco.
+     *
+     * @access protected
+     */
+    function _addSubSeccion(&$MARCO) {
+        if ($this->subseccion) {
+            $tmp = $MARCO->strlen($this->subseccion, $this->_config['subseccion']);
+            $tmp2 = $this->_config['linea2']['Xi'] - $this->_config['linea1']['Xi'];
+            if ($tmp >= $tmp2) {
+                $this->subseccion = $MARCO->wrapLine ($this->subseccion, $tmp2,
+                        $this->_config['subseccion']);
+                $tmp = $MARCO->strlen($this->subseccion, $this->_config['subseccion']);
+            }
+            $init = $this->_config['linea1']['Xi'] + ( $this->_config['linea2']['Xi'] 
+                    - $this->_config['linea1']['Xi'] - $tmp) / 2; 
+            $MARCO->addText($init, $this->_config['subseccion']['Y'], $this->subseccion, 
+                    $this->_config['subseccion']);
+        }
+    }
+
+    /**
+     * Funcion que agrega el paginador al encabezado de una pagina.
+     *
+     * @return void
+     * @param &Object $MARCO MECON_PDF_Marco.
+     *
+     * @access protected
+     */
+    function _addPager(&$MARCO) {
+        if ($this->paginador) {
+            $txt = 'Página '.$MARCO->numPage().' de '.
+                $MARCO->countPages();
+            $tmp = $MARCO->strlen($txt, $this->_config['paginador']);
+            $init = $this->_config['linea2']['Xi'] + ( $this->_config['Xf'] 
+                    - $this->_config['linea2']['Xi'] - $tmp) / 2; 
+            $MARCO->addText($init, $this->_config['paginador']['Y'], $txt, 
+                    $this->_config['paginador']);
+        }
+    }
+    
+    /**
+     * Funcion que permite agregar la fecha al encabezado de una pagina.
+     *
+     * @return void
+     * @param &Object $MARCO MECON_PDF_Marco.
+     *
+     * @access protected
+     */
+    function _addDate(&$MARCO) {
+        if ($this->fecha) {
+            if (is_a($this->fecha, 'Date')) {
+                $this->fecha = $this->fecha->format("%d/%m/%Y");
+            }
+            elseif ($this->fecha === true) {
+                $this->fecha = date("d/m/Y");
+            }
+            $tmp = $MARCO->strlen($this->fecha, $this->_config['fecha']);
+            $init = $this->_config['linea2']['Xi'] + ( $this->_config['Xf'] 
+                    - $this->_config['linea2']['Xi'] - $tmp) / 2; 
+            $MARCO->addText($init, $this->_config['fecha']['Y'], $this->fecha,
+                    $this->_config['fecha']);
+        }
+    }
+    
+    /**
+     * Funcion que arma el recuadro del encabezado de las paginas.
+     * 
+     * @return void
+     * @param &Object $MARCO MECON_PDF_Marco.
+     *
+     * @access protected
+     */
+    function _addHeaderRectangle(&$MARCO) {
+        //Armo el recuadro
+        $MARCO->addRectangle ($this->_config['Xi'], $this->_config['Yi'], 
+                $this->_config['Xf'], $this->_config['Yf'], '');
+        $MARCO->addLine($this->_config['linea1']['Xi'], 
+                $this->_config['linea1']['Yi'], $this->_config['linea1']['Xf'], 
+                $this->_config['linea1']['Yf'], '');
+        $MARCO->addLine($this->_config['linea2']['Xi'], 
+                $this->_config['linea2']['Yi'], $this->_config['linea2']['Xf'], 
+                $this->_config['linea2']['Yf'], '');
+    }
+}
+?>
\ No newline at end of file
diff --git a/lib/MECON/PDF/HeaderDefecto/medidas.php b/lib/MECON/PDF/HeaderDefecto/medidas.php
new file mode 100644 (file)
index 0000000..f9da1d8
--- /dev/null
@@ -0,0 +1,260 @@
+<?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80 foldmethod=marker:
+-------------------------------------------------------------------------------
+                             Ministerio de Economía
+                                    meconlib
+-------------------------------------------------------------------------------
+This file is part of meconlib.
+
+meconlib is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option)
+any later version.
+
+meconlib is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+You should have received a copy of the GNU General Public License; if not,
+write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+Boston, MA  02111-1307  USA
+-------------------------------------------------------------------------------
+Creado: mar abr 27 12:44:27 ART 2004
+Autor:  Martin Marrese <mmarre@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id$
+-----------------------------------------------------------------------------*/
+
+/**
+ * Este archivo contiene las coordenadas y estilos de los diferentes componentes
+ * de MECON_PDF_Marco. Las cordenadas Arrancan en (0,0)
+
+    Y ^
+      |
+   Yn +------------+  
+      |            |
+      |            |
+      |            |
+      |            |
+      |            |
+      |            |
+      |            |
+    0 +------------+----->
+      0            Xn    X
+ */
+
+
+/**
+ * Medidas para cada formato de pagina.
+ */
+return array (
+        // A4 {{{
+        'a4' => array (
+                //Portrait {{{ 
+                'portrait' => array (
+                        //Encabezado {{{
+                        'encabezado' => array ( //Encabezado de cada pagina
+                                'Xi' => 0,
+                                'Xf' => 530,
+                                'Yi' => 657,  
+                                'Yf' => 700, //Siempre debe representar la altura maxima de la pagina
+                                'logo' => array (
+                                        'X' => 7,
+                                        'Y' => 665,
+                                        'path' =>
+                                        '/var/www/meconlib/www/images/pdf_logo_portrait.jpg',
+                                    ),
+                                'linea1' => array (
+                                        'Xi' => 150,
+                                        'Xf' => 150,
+                                        'Yi' => 657,
+                                        'Yf' => 700,
+                                    ),
+                                'linea2' => array (
+                                        'Xi' => 444,
+                                        'Xf' => 444,
+                                        'Yi' => 657,
+                                        'Yf' => 700,
+                                    ),
+                                'seccion' => array (
+                                        'Y'      => 685,
+                                        'font'   => 'Helvetica-Bold',
+                                        'height' => 12,
+                                    ),
+                                'subseccion' => array (
+                                        'Y'      => 664,
+                                        'font'   => 'Helvetica',
+                                        'height' => 12,
+                                    ),
+                                'paginador' => array (
+                                        'Y'      => 685,
+                                        'font'   => 'Helvetica',
+                                        'height' => 9,
+                                    ),
+                                'fecha' => array (
+                                        'Y'      => 664,
+                                        'font'   => 'Helvetica',
+                                        'height' => 9,
+                                    ),
+                            ),
+                        //}}}
+                    ),
+                //}}}
+                //LandScape {{{
+                'landscape' => array (
+                        //Encabezado {{{
+                        'encabezado' => array ( //Encabezado de cada pagina
+                                'Xi' => 0,
+                                'Yi' => 487,
+                                'Xf' => 700,
+                                'Yf' => 530,
+                                'logo' => array (
+                                        'X' => 7,
+                                        'Y' => 495,
+                                        'path' =>
+                                        '/var/www/meconlib/www/images/pdf_logo_portrait.jpg',
+                                    ),
+                                'linea1' => array (
+                                        'Xi' => 150,
+                                        'Xf' => 150,
+                                        'Yi' => 487,
+                                        'Yf' => 530,
+                                    ),
+                                'linea2' => array (
+                                        'Xi' => 614,
+                                        'Xf' => 614,
+                                        'Yi' => 487,
+                                        'Yf' => 530,
+                                    ),
+                                'seccion' => array (
+                                        'Y'      => 515,
+                                        'font'   => 'Helvetica-Bold',
+                                        'height' => 12,
+                                    ),
+                                'subseccion' => array (
+                                        'Y'      => 494,
+                                        'font'   => 'Helvetica',
+                                        'height' => 12,
+                                    ),
+                                'paginador' => array (
+                                        'Y'      => 515,
+                                        'font'   => 'Helvetica',
+                                        'height' => 9,
+                                    ),
+                                'fecha' => array (
+                                        'Y'      => 494,
+                                        'font'   => 'Helvetica',
+                                        'height' => 9,
+                                    ),
+                            ),
+                        //}}}
+                    ), 
+                //}}}
+            ),
+        //}}}
+        // OFICIO {{{
+        'legal' => array (
+                //Portrait {{{ 
+                'portrait' => array (
+                        //Encabezado {{{
+                        'encabezado' => array ( //Encabezado de cada pagina
+                                'Xi' => 0,
+                                'Xf' => 540,
+                                'Yi' => 821,  
+                                'Yf' => 864, //Siempre debe representar la altura maxima de la pagina
+                                'logo' => array (
+                                        'X' => 7,
+                                        'Y' => 829,
+                                        'path' =>
+                                        '/var/www/meconlib/www/images/pdf_logo_portrait.jpg',
+                                    ),
+                                'linea1' => array (
+                                        'Xi' => 150,
+                                        'Xf' => 150,
+                                        'Yi' => 821,
+                                        'Yf' => 864,
+                                    ),
+                                'linea2' => array (
+                                        'Xi' => 454,
+                                        'Xf' => 454,
+                                        'Yi' => 821,
+                                        'Yf' => 864,
+                                    ),
+                                'seccion' => array (
+                                        'Y'      => 849,
+                                        'font'   => 'Helvetica-Bold',
+                                        'height' => 12,
+                                    ),
+                                'subseccion' => array (
+                                        'Y'      => 828,
+                                        'font'   => 'Helvetica',
+                                        'height' => 12,
+                                    ),
+                                'paginador' => array (
+                                        'Y'      => 849,
+                                        'font'   => 'Helvetica',
+                                        'height' => 9,
+                                    ),
+                                'fecha' => array (
+                                        'Y'      => 828,
+                                        'font'   => 'Helvetica',
+                                        'height' => 9,
+                                    ),
+                            ),
+                        //}}}
+                    ),
+                //}}}
+                //LandScape {{{
+                'landscape' => array (
+                        //Encabezado {{{
+                        'encabezado' => array ( //Encabezado de cada pagina
+                                'Xi' => 0,
+                                'Yi' => 497,
+                                'Xf' => 864,
+                                'Yf' => 540,
+                                'logo' => array (
+                                        'X' => 7,
+                                        'Y' => 505,
+                                        'path' =>
+                                        '/var/www/meconlib/www/images/pdf_logo_portrait.jpg',
+                                    ),
+                                'linea1' => array (
+                                        'Xi' => 150,
+                                        'Xf' => 150,
+                                        'Yi' => 497,
+                                        'Yf' => 540,
+                                    ),
+                                'linea2' => array (
+                                        'Xi' => 778,
+                                        'Xf' => 778,
+                                        'Yi' => 497,
+                                        'Yf' => 540,
+                                    ),
+                                'seccion' => array (
+                                        'Y'      => 525,
+                                        'font'   => 'Helvetica-Bold',
+                                        'height' => 12,
+                                    ),
+                                'subseccion' => array (
+                                        'Y'      => 504,
+                                        'font'   => 'Helvetica',
+                                        'height' => 12,
+                                    ),
+                                'paginador' => array (
+                                        'Y'      => 525,
+                                        'font'   => 'Helvetica',
+                                        'height' => 9,
+                                    ),
+                                'fecha' => array (
+                                        'Y'      => 504,
+                                        'font'   => 'Helvetica',
+                                        'height' => 9,
+                                    ),
+                            ),
+                        //}}}
+                    ), 
+                //}}}
+            ),
+        //}}}
+        );
+
+?>
index 42fc4cbe76f12a4ed85c39501106a2d3dbd9f90f..0005392fb34f549e0a9f9e92faf32220a3bce97d 100644 (file)
@@ -26,6 +26,7 @@ $Id$
 
 require_once 'MECON/PDF.php';
 require_once 'MECON/PDF/Separador.php';
+require_once 'MECON/PDF/HeaderDefecto.php';
 
 /**
  * Libreria que crea un marco estandar para los pdfs.
@@ -110,6 +111,14 @@ class MECON_PDF_Marco extends MECON_PDF {
      * @access protected
      */
     var $_excepciones = array ();
+
+    /**
+     * MECON_PDF_Header. Objeto que hay que utilizar como enzabezado. Si hay
+     * algo aqui se desecha el encabezado por defecto.
+     * @var Object $header
+     * @access public
+     */
+    var $header = null;
      
     /**
      * Class constructor.
@@ -146,9 +155,6 @@ class MECON_PDF_Marco extends MECON_PDF {
         $tmp['Xf'] = $this->_config['Xf'];
         $tmp['Yf'] = $this->_config['Yf'];
         $this->_config = $tmp;
-        if (@$this->_config['encabezado']['logo']['path']) {
-            $this->logo = $this->_config['encabezado']['logo']['path'];
-        }
     }
 
     /**
@@ -165,13 +171,12 @@ class MECON_PDF_Marco extends MECON_PDF {
      * @return void
      * @access public
      */
-    function newPage($pagina = 'a4', $orientacion = null, $encabezado = true, $seccion = null, $subseccion =
-            null)
-    {   
+    function newPage($pagina = 'a4', $orientacion = null, $encabezado = true, 
+            $seccion = null, $subseccion = null) {   
         parent::newPage($pagina, $orientacion);
         $this->_resetConf();
         if ($encabezado) {
-            $this->espacioDisponible = $this->_config['encabezado']['Yi'] - 27;
+            $this->espacioDisponible = $this->header->getAltura() - 27;
             if ($this->countPages() === 1) {
                 if ($this->titulo || $this->subtitulo) {
                     $this->espacioDisponible -= 27;
@@ -185,137 +190,12 @@ class MECON_PDF_Marco extends MECON_PDF {
             }
         }
         else {
-            $this->espacioDisponible = $this->_config['encabezado']['Yf'];
+            $this->espacioDisponible = $this->_config['Yf'];
             $this->_excepciones[$this->countPages()]['nova'] = true;
             
         }
     }
 
-    /**
-     * Funcion que agrega el logo al encabezado de una pagina.
-     *
-     * @return void
-     * @access protected
-     */
-    function _addLogo() {
-        $this->_resetConf();
-        $conf = $this->_config['encabezado'];
-        if ($this->logo) {
-            $this->addImage($this->logo, $conf['logo']['X'],
-                    $conf['logo']['Y'], null, 'jpg');
-        }
-    }
-
-    /**
-     * Funcion que agrega la seccion al encabezado de una pagina.
-     *
-     * @return void
-     * @access protected
-     */
-    function _addSeccion() {
-        $this->_resetConf();
-        $conf = $this->_config['encabezado'];
-        if ($this->seccion) {
-            $tmp = $this->strlen($this->seccion, $conf['seccion']);
-            $tmp2 = $conf['linea2']['Xi'] - $conf['linea1']['Xi'];
-            if ($tmp >= $tmp2) {
-                $this->seccion = $this->wrapLine ($this->seccion, $tmp2,
-                        $conf['seccion']);
-                $tmp = $this->strlen($this->seccion, $conf['seccion']);
-            }
-            $init = $conf['linea1']['Xi'] + ( $conf['linea2']['Xi'] 
-                    - $conf['linea1']['Xi'] - $tmp) / 2; 
-            $this->addText($init, $conf['seccion']['Y'], $this->seccion,
-                    $conf['seccion']);
-        }
-    }
-   
-    /**
-     * Funcion que agrega la subseccion al encabezado de una pagina.
-     *
-     * @return void
-     * @access protected
-     */
-    function _addSubSeccion() {
-        $this->_resetConf();
-        $conf = $this->_config['encabezado'];
-        if ($this->subseccion) {
-            $tmp = $this->strlen($this->subseccion, $conf['subseccion']);
-            $tmp2 = $conf['linea2']['Xi'] - $conf['linea1']['Xi'];
-            if ($tmp >= $tmp2) {
-                $this->subseccion = $this->wrapLine ($this->subseccion, $tmp2,
-                        $conf['subseccion']);
-                $tmp = $this->strlen($this->subseccion, $conf['subseccion']);
-            }
-            $init = $conf['linea1']['Xi'] + ( $conf['linea2']['Xi'] 
-                    - $conf['linea1']['Xi'] - $tmp) / 2; 
-            $this->addText($init, $conf['subseccion']['Y'], $this->subseccion, 
-                    $conf['subseccion']);
-        }
-    }
-
-    /**
-     * Funcion que agrega el paginador al encabezado de una pagina.
-     *
-     * @return void
-     * @access protected
-     */
-    function _addPager() {
-        $this->_resetConf();
-        $conf = $this->_config['encabezado'];
-        if ($this->paginador) {
-            $txt = 'Página '.$this->numPage().' de '.
-                $this->countPages();
-            $tmp = $this->strlen($txt, $conf['paginador']);
-            $init = $conf['linea2']['Xi'] + ( $conf['Xf'] 
-                    - $conf['linea2']['Xi'] - $tmp) / 2; 
-            $this->addText($init, $conf['paginador']['Y'], $txt, 
-                    $conf['paginador']);
-        }
-    }
-    
-    /**
-     * Funcion que permite agregar la fecha al encabezado de una pagina.
-     *
-     * @return void
-     * @access protected
-     */
-    function _addDate() {
-        $this->_resetConf();
-        $conf = $this->_config['encabezado'];
-        if ($this->fecha) {
-            if (is_a($this->fecha, 'Date')) {
-                $this->fecha = $this->fecha->format("%d/%m/%Y");
-            }
-            elseif ($this->fecha === true) {
-                $this->fecha = date("d/m/Y");
-            }
-            $tmp = $this->strlen($this->fecha, $conf['fecha']);
-            $init = $conf['linea2']['Xi'] + ( $conf['Xf'] 
-                    - $conf['linea2']['Xi'] - $tmp) / 2; 
-            $this->addText($init, $conf['fecha']['Y'], $this->fecha,
-                    $conf['fecha']);
-        }
-    }
-    
-    /**
-     * Funcion que arma el recuadro del encabezado de las paginas.
-     * 
-     * @return void
-     * @access protected
-     */
-    function _addHeaderRectangle() {
-        $this->_resetConf();
-        $conf = $this->_config['encabezado'];
-        //Armo el recuadro
-        $this->addRectangle ($conf['Xi'], $conf['Yi'], $conf['Xf'], 
-                    $conf['Yf'], '');
-        $this->addLine($conf['linea1']['Xi'], $conf['linea1']['Yi'], 
-                $conf['linea1']['Xf'], $conf['linea1']['Yf'], '');
-        $this->addLine($conf['linea2']['Xi'], $conf['linea2']['Yi'], 
-                $conf['linea2']['Xf'], $conf['linea2']['Yf'], '');
-    }
-
     /**
      * Funcion que permite agregar el titulo a una pagina.
      *
@@ -372,13 +252,8 @@ class MECON_PDF_Marco extends MECON_PDF {
      * @access protected
      */
     function _buildHeader($title = true, $subtitle = true) {
-        $this->_resetConf();
-        $this->_addLogo();
-        $this->_addSeccion();
-        $this->_addSubseccion();
-        $this->_addPager();
-        $this->_addDate();
-        $this->_addHeaderRectangle();
+        //Agrego el header.
+        $this->header->toPdf($this);
         if ($title) {
             $this->_addTitle();
         }
@@ -387,6 +262,24 @@ class MECON_PDF_Marco extends MECON_PDF {
         }
     }
 
+    /**
+     * Funcion que crea el Header por defecto.
+     *
+     * @return void
+     * @access protected
+     */
+    function _crearHeaderDefecto() {
+        $this->header =& new MECON_PDF_HeaderDefecto($this->tamanio,
+                $this->getOrientation($this->numPage()));
+        if (@$this->logo) {
+            $this->header->logo = $this->logo;
+        }
+        $this->header->seccion = $this->seccion;
+        $this->header->subseccion = $this->subseccion;
+        $this->header->paginador = $this->paginador;
+        $this->header->fecha = $this->fecha;
+    }
+    
     /**
      * Funcion que agrega el contenido al PDF.
      *
@@ -413,32 +306,38 @@ class MECON_PDF_Marco extends MECON_PDF {
      * @access public
      */
     function toPDF() {
+        //Veo si hay que utilizar o no el header por defecto.
+        if (!$this->header) {
+            $this->_crearHeaderDefecto();
+        }
+        
         $this->_buildContent();
         if ($this->getPages()) {
             $t = true;
             foreach ($this->getPages() as $page) {
                 $this->_pagina_actual = $page;
                 
-                $sec = $this->seccion;
-                $subsec = $this->subseccion;
+                $sec = $this->header->seccion;
+                $subsec = $this->header->subseccion;
                 
                 if (@$this->_excepciones[$this->numPage($page)]['seccion']) {
-                    $this->seccion = 
+                    $this->header->seccion = 
                         $this->_excepciones[$this->numPage($page)]['seccion'];
                 }
                 
                 if (@$this->_excepciones[$this->numPage($page)]['subseccion']) {
-                    $this->subseccion = 
+                    $this->header->subseccion = 
                         $this->_excepciones[$this->numPage($page)]['subseccion'];
                 }
                 
                 if (@!$this->_excepciones[$this->numPage($page)]['nova']) {
                     $this->_buildHeader($t, $t);      
                 }
+                //Solo agrego el titulo y subtitulo en la primer hoja
                 $t = false;
                 
-                $this->seccion = $sec;
-                $this->subseccion = $subsec;
+                $this->header->seccion = $sec;
+                $this->header->subseccion = $subsec;
             }
         return parent::toPDF();
         }
index 032fa64c57d7f1d7afbd38491df628cf91117ca1..153db16b4b7a02cfbbb69223ade099f23838f451 100644 (file)
@@ -51,52 +51,6 @@ return array (
         'a4' => array (
                 //Portrait {{{ 
                 'portrait' => array (
-                        //Encabezado {{{
-                        'encabezado' => array ( //Encabezado de cada pagina
-                                'Xi' => 0,
-                                'Xf' => 530,
-                                'Yi' => 657,  
-                                'Yf' => 700, //Siempre debe representar la altura maxima de la pagina
-                                'logo' => array (
-                                        'X' => 7,
-                                        'Y' => 665,
-                                        'path' =>
-                                        '/var/www/meconlib/www/images/pdf_logo_portrait.jpg',
-                                    ),
-                                'linea1' => array (
-                                        'Xi' => 150,
-                                        'Xf' => 150,
-                                        'Yi' => 657,
-                                        'Yf' => 700,
-                                    ),
-                                'linea2' => array (
-                                        'Xi' => 444,
-                                        'Xf' => 444,
-                                        'Yi' => 657,
-                                        'Yf' => 700,
-                                    ),
-                                'seccion' => array (
-                                        'Y'      => 685,
-                                        'font'   => 'Helvetica-Bold',
-                                        'height' => 12,
-                                    ),
-                                'subseccion' => array (
-                                        'Y'      => 664,
-                                        'font'   => 'Helvetica',
-                                        'height' => 12,
-                                    ),
-                                'paginador' => array (
-                                        'Y'      => 685,
-                                        'font'   => 'Helvetica',
-                                        'height' => 9,
-                                    ),
-                                'fecha' => array (
-                                        'Y'      => 664,
-                                        'font'   => 'Helvetica',
-                                        'height' => 9,
-                                    ),
-                            ),
-                        //}}}
                         //Titulos {{{
                         'titulo' => array (
                                     'Y'      => 630,
@@ -113,52 +67,6 @@ return array (
                 //}}}
                 //LandScape {{{
                 'landscape' => array (
-                        //Encabezado {{{
-                        'encabezado' => array ( //Encabezado de cada pagina
-                                'Xi' => 0,
-                                'Yi' => 487,
-                                'Xf' => 700,
-                                'Yf' => 530,
-                                'logo' => array (
-                                        'X' => 7,
-                                        'Y' => 495,
-                                        'path' =>
-                                        '/var/www/meconlib/www/images/pdf_logo_portrait.jpg',
-                                    ),
-                                'linea1' => array (
-                                        'Xi' => 150,
-                                        'Xf' => 150,
-                                        'Yi' => 487,
-                                        'Yf' => 530,
-                                    ),
-                                'linea2' => array (
-                                        'Xi' => 614,
-                                        'Xf' => 614,
-                                        'Yi' => 487,
-                                        'Yf' => 530,
-                                    ),
-                                'seccion' => array (
-                                        'Y'      => 515,
-                                        'font'   => 'Helvetica-Bold',
-                                        'height' => 12,
-                                    ),
-                                'subseccion' => array (
-                                        'Y'      => 494,
-                                        'font'   => 'Helvetica',
-                                        'height' => 12,
-                                    ),
-                                'paginador' => array (
-                                        'Y'      => 515,
-                                        'font'   => 'Helvetica',
-                                        'height' => 9,
-                                    ),
-                                'fecha' => array (
-                                        'Y'      => 494,
-                                        'font'   => 'Helvetica',
-                                        'height' => 9,
-                                    ),
-                            ),
-                        //}}}
                         //Titulos {{{
                         'titulo' => array (
                                     'Y'      => 460,
@@ -179,52 +87,6 @@ return array (
         'legal' => array (
                 //Portrait {{{ 
                 'portrait' => array (
-                        //Encabezado {{{
-                        'encabezado' => array ( //Encabezado de cada pagina
-                                'Xi' => 0,
-                                'Xf' => 540,
-                                'Yi' => 821,  
-                                'Yf' => 864, //Siempre debe representar la altura maxima de la pagina
-                                'logo' => array (
-                                        'X' => 7,
-                                        'Y' => 829,
-                                        'path' =>
-                                        '/var/www/meconlib/www/images/pdf_logo_portrait.jpg',
-                                    ),
-                                'linea1' => array (
-                                        'Xi' => 150,
-                                        'Xf' => 150,
-                                        'Yi' => 821,
-                                        'Yf' => 864,
-                                    ),
-                                'linea2' => array (
-                                        'Xi' => 454,
-                                        'Xf' => 454,
-                                        'Yi' => 821,
-                                        'Yf' => 864,
-                                    ),
-                                'seccion' => array (
-                                        'Y'      => 849,
-                                        'font'   => 'Helvetica-Bold',
-                                        'height' => 12,
-                                    ),
-                                'subseccion' => array (
-                                        'Y'      => 828,
-                                        'font'   => 'Helvetica',
-                                        'height' => 12,
-                                    ),
-                                'paginador' => array (
-                                        'Y'      => 849,
-                                        'font'   => 'Helvetica',
-                                        'height' => 9,
-                                    ),
-                                'fecha' => array (
-                                        'Y'      => 828,
-                                        'font'   => 'Helvetica',
-                                        'height' => 9,
-                                    ),
-                            ),
-                        //}}}
                         //Titulos {{{
                         'titulo' => array (
                                     'Y'      => 794,
@@ -241,52 +103,6 @@ return array (
                 //}}}
                 //LandScape {{{
                 'landscape' => array (
-                        //Encabezado {{{
-                        'encabezado' => array ( //Encabezado de cada pagina
-                                'Xi' => 0,
-                                'Yi' => 497,
-                                'Xf' => 864,
-                                'Yf' => 540,
-                                'logo' => array (
-                                        'X' => 7,
-                                        'Y' => 505,
-                                        'path' =>
-                                        '/var/www/meconlib/www/images/pdf_logo_portrait.jpg',
-                                    ),
-                                'linea1' => array (
-                                        'Xi' => 150,
-                                        'Xf' => 150,
-                                        'Yi' => 497,
-                                        'Yf' => 540,
-                                    ),
-                                'linea2' => array (
-                                        'Xi' => 778,
-                                        'Xf' => 778,
-                                        'Yi' => 497,
-                                        'Yf' => 540,
-                                    ),
-                                'seccion' => array (
-                                        'Y'      => 525,
-                                        'font'   => 'Helvetica-Bold',
-                                        'height' => 12,
-                                    ),
-                                'subseccion' => array (
-                                        'Y'      => 504,
-                                        'font'   => 'Helvetica',
-                                        'height' => 12,
-                                    ),
-                                'paginador' => array (
-                                        'Y'      => 525,
-                                        'font'   => 'Helvetica',
-                                        'height' => 9,
-                                    ),
-                                'fecha' => array (
-                                        'Y'      => 504,
-                                        'font'   => 'Helvetica',
-                                        'height' => 9,
-                                    ),
-                            ),
-                        //}}}
                         //Titulos {{{
                         'titulo' => array (
                                     'Y'      => 470,