* @var arary $config
* @access protected
*/
- var $config;
+ var $_config = array ();
/**
* Libreria externa.
function MECON_PDF($tam = "a4")
{
$this->_pdf = new pdffile;
- $this->config = include 'MECON/PDF/medidas.php';
- $this->config = $this->config[$tam];
+ $this->_config = include 'MECON/PDF/medidas.php';
+ $this->_config = $this->_config[$tam];
}
/**
* @return void
* @access public
*/
- function addText($X, $Y, $texto, $estilo = '', $pag = null, $transformacion =
- '')
- {
+ function addText($X, $Y, $texto, $estilo = '', $pag = null, $transformacion = '') {
+ //@TODO Ver si $texto es un objeto
+
$x = $X;
$y = $Y;
switch (strtolower($transformacion)) {
{
switch (strtolower($orientacion)) {
case 'landscape':
- $width = $this->config['Yf'] - $this->config['Yi'];
+ $width = $this->_config['Yf'] - $this->_config['Yi'];
break;
default:
- $width = $this->config['Xf'] - $this->config['Xi'];
+ $width = $this->_config['Xf'] - $this->_config['Xi'];
}
return $width;
{
switch (strtolower($orientacion)) {
case 'landscape':
- $height = $this->config['Xf'] - $this->config['Xi'];
+ $height = $this->_config['Xf'] - $this->_config['Xi'];
break;
default:
- $height = $this->config['Yf'] - $this->config['Yi'];
+ $height = $this->_config['Yf'] - $this->_config['Yi'];
}
return $height;
}
*/
function _landscapeX($x, $y)
{
- return -$y + $this->config['Xf'];
+ return -$y + $this->_config['Xf'];
}
/**
*/
function _landscapeY($x, $y)
{
- return $x + $this->config['Yi'];
+ return $x + $this->_config['Yi'];
}
/**
*/
function _portraitX($x, $y)
{
- return $x + $this->config['Xi'];
+ return $x + $this->_config['Xi'];
}
/**
*/
function _portraitY($x, $y)
{
- return $y + $this->config['Yi'];
+ return $y + $this->_config['Yi'];
}
}
?>
\ No newline at end of file
--- /dev/null
+<?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: jue nov 6 16:13:38 ART 2003
+Autor: Martin Marrese <mmarre@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id$
+-----------------------------------------------------------------------------*/
+
+/**
+ * Libreria de Contenidos PDF.
+ */
+class MECON_PDF_Contenido {
+
+ /**
+ * Class Constructor. Para que se aviven de redefinir este metodo
+ *
+ * @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);
+ }
+
+}
+?>
\ No newline at end of file
--- /dev/null
+<?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: jue nov 6 16:13:38 ART 2003
+Autor: Martin Marrese <mmarre@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id$
+-----------------------------------------------------------------------------*/
+
+require_once 'MECON/PDF/Contenido.php';
+
+/**
+ * Libreria de imagenes para PDF.
+ */
+class MECON_PDF_Imagen extends MECON_PDF_Contenido {
+
+}
+?>
\ No newline at end of file
-----------------------------------------------------------------------------*/
require_once 'MECON/PDF.php';
-require_once 'MECON/HTML/Tabla.php';
/**
* Libreria que crea un marco estandar para los pdfs.
*/
-class MECON_PDF_Marco extends MECON_HTML_Tabla {
-
- /**
- * Objeto MECON_PDF
- * @var Object MECON_PDF
- * @access protected
- */
- var $_pdf;
-
- /**
- * Archivo de configuracion de medidas
- * @var array $conf
- * @access protected
- */
- var $_config = array ();
+class MECON_PDF_Marco extends MECON_PDF {
/**
* Tamanio de las paginas.
* @var string $tamanio
- * @access protected
+ * @access public
*/
- var $_tamanio = "a4";
+ var $tamanio = "a4";
/**
* Orientacion (portrait o landscape).
* @var sting $orientacion
+ * @access public
+ */
+ var $orientacion = "portrait";
+
+ /**
+ * Array de objetos MECON_PDF_Contenido
+ @ @var array $contenido
* @access protected
*/
- var $_orientacion = "portrait";
+ var $_contenido = array();
+ /**
+ * Espacio dispobible en la pagina. Representa la coordenada Y a partir de
+ * la cual se puede comenzar a escribir el contenido.
+ * @var int $espacioDisponible
+ * @access public
+ */
+ var $espacioDisponible;
+
/**
* Logo.
* @var string $logo
*/
var $subtitulo;
+ /**
+ * Excepciones al encabezado
+ * @var array $excepciones
+ * @access protected
+ */
+ var $_excepciones = array ();
+
/**
* Class constructor.
*
* @access public
*/
function MECON_PDF_Marco($tam = "a4", $ori = "portrait") {
- $this->_pdf =& new MECON_PDF($tam);
- $this->_tamanio = $tam;
- $this->_orientacion = $ori;
- $this->_config = include 'MECON/PDF/Marco/medidas.php' ;
- $this->_config = $this->_config[$tam][$ori];
+ $this->MECON_PDF($tam);
+ $this->tamanio = $tam;
+ $this->orientacion = $ori;
+ $tmp = include 'MECON/PDF/Marco/medidas.php' ;
+ $tmp = $tmp[$tam][$ori];
+ $tmp['Xi'] = $this->_config['Xi'];
+ $tmp['Yi'] = $this->_config['Yi'];
+ $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'];
}
- $this->_config['Xi'] = $this->_pdf->config['Xi'];
- $this->_config['Yi'] = $this->_pdf->config['Yi'];
- $this->_config['Xf'] = $this->_pdf->config['Xf'];
- $this->_config['Yf'] = $this->_pdf->config['Yf'];
- $this->MECON_HTML_Tabla();
+ }
+
+ /**
+ * Permite agregar nuevas paginas al pdf que se esta armando.
+ *
+ * @param string $pagina Tipo de pagina que se va a utilizar.
+ * @param bool $encabezado Indica si el encabezado debe ponerse en la
+ * pagina.
+ * @param string $seccion Seccion del encabezado para esta pagina nueva.
+ * @param string $subseccion SubSeccion del encabezado para esta pagina
+ * nueva.
+ *
+ * @return void
+ * @access public
+ */
+ function newPage($pagina = 'a4', $encabezado = true, $seccion = null, $subseccion =
+ null)
+ {
+ parent::newPage($pagina);
+ if ($encabezado) {
+ $this->espacioDisponible = $this->_config['encabezado']['Yi'] - 27;
+ if ($this->countPages() === 1) {
+ if ($this->titulo || $this->subtitulo) {
+ $this->espacioDisponible -= 27;
+ }
+ }
+ if (!is_null($seccion)) {
+ $this->excepciones[$this->countPages()]['seccion'] = $seccion;
+ }
+ if (!is_null($subseccion)) {
+ $this->excepciones[$this->countPages()]['subseccion'] = $subseccion;
+ }
+ }
+ else {
+ $this->espacioDisponible = $this->_config['encabezado']['Yf'];
+ $this->excepciones[$this->countPages()]['nova'] = true;
+
+ }
}
/**
function _addLogo() {
$conf = $this->_config['encabezado'];
if ($this->logo) {
- $this->_pdf->addImage($this->logo, $conf['logo']['X'],
- $conf['logo']['Y'], null, 'jpg', $this->_orientacion);
+ $this->addImage($this->logo, $conf['logo']['X'],
+ $conf['logo']['Y'], null, 'jpg', $this->orientacion);
}
}
function _addSeccion() {
$conf = $this->_config['encabezado'];
if ($this->seccion) {
- $tmp = $this->_pdf->strlen($this->seccion, $conf['seccion']);
+ $tmp = $this->strlen($this->seccion, $conf['seccion']);
$tmp2 = $conf['linea2']['Xi'] - $conf['linea1']['Xi'];
if ($tmp >= $tmp2) {
- $this->seccion = $this->_pdf->wrapLine ($this->seccion, $tmp2,
+ $this->seccion = $this->wrapLine ($this->seccion, $tmp2,
$conf['seccion']);
- $tmp = $this->_pdf->strlen($this->seccion, $conf['seccion']);
+ $tmp = $this->strlen($this->seccion, $conf['seccion']);
}
$init = $conf['linea1']['Xi'] + ( $conf['linea2']['Xi']
- $conf['linea1']['Xi'] - $tmp) / 2;
- $this->_pdf->addText($init, $conf['seccion']['Y'], $this->seccion,
- $conf['seccion'], null, $this->_orientacion);
+ $this->addText($init, $conf['seccion']['Y'], $this->seccion,
+ $conf['seccion'], null, $this->orientacion);
}
}
function _addSubSeccion() {
$conf = $this->_config['encabezado'];
if ($this->subseccion) {
- $tmp = $this->_pdf->strlen($this->subseccion, $conf['subseccion']);
+ $tmp = $this->strlen($this->subseccion, $conf['subseccion']);
$tmp2 = $conf['linea2']['Xi'] - $conf['linea1']['Xi'];
if ($tmp >= $tmp2) {
- $this->subseccion = $this->_pdf->wrapLine ($this->subseccion, $tmp2,
+ $this->subseccion = $this->wrapLine ($this->subseccion, $tmp2,
$conf['subseccion']);
- $tmp = $this->_pdf->strlen($this->subseccion, $conf['subseccion']);
+ $tmp = $this->strlen($this->subseccion, $conf['subseccion']);
}
$init = $conf['linea1']['Xi'] + ( $conf['linea2']['Xi']
- $conf['linea1']['Xi'] - $tmp) / 2;
- $this->_pdf->addText($init, $conf['subseccion']['Y'], $this->subseccion,
- $conf['subseccion'], null, $this->_orientacion);
+ $this->addText($init, $conf['subseccion']['Y'], $this->subseccion,
+ $conf['subseccion'], null, $this->orientacion);
}
}
function _addPager() {
$conf = $this->_config['encabezado'];
if ($this->paginador) {
- $txt = 'Pagina '.$this->_pdf->numPage().' de '.
- $this->_pdf->countPages();
- $tmp = $this->_pdf->strlen($txt, $conf['paginador']);
+ $txt = 'Pagina '.$this->numPage().' de '.
+ $this->countPages();
+ $tmp = $this->strlen($txt, $conf['paginador']);
$init = $conf['linea2']['Xi'] + ( $conf['Xf']
- $conf['linea2']['Xi'] - $tmp) / 2;
- $this->_pdf->addText($init, $conf['paginador']['Y'], $txt,
- $conf['paginador'], null, $this->_orientacion);
+ $this->addText($init, $conf['paginador']['Y'], $txt,
+ $conf['paginador'], null, $this->orientacion);
}
}
function _addDate() {
$conf = $this->_config['encabezado'];
if ($this->fecha) {
+ //@TODO Ver si es un objeto DATE
if ($this->fecha === true) {
$this->fecha = date("d/m/Y");
}
- $tmp = $this->_pdf->strlen($this->fecha, $conf['fecha']);
+ $tmp = $this->strlen($this->fecha, $conf['fecha']);
$init = $conf['linea2']['Xi'] + ( $conf['Xf']
- $conf['linea2']['Xi'] - $tmp) / 2;
- $this->_pdf->addText($init, $conf['fecha']['Y'], $this->fecha,
- $conf['fecha'], null, $this->_orientacion);
+ $this->addText($init, $conf['fecha']['Y'], $this->fecha,
+ $conf['fecha'], null, $this->orientacion);
}
}
function _addHeaderRectangle() {
$conf = $this->_config['encabezado'];
//Armo el recuadro
- $this->_pdf->addRectangle ($conf['Xi'], $conf['Yi'], $conf['Xf'],
- $conf['Yf'], '', null, $this->_orientacion);
- $this->_pdf->addLine($conf['linea1']['Xi'], $conf['linea1']['Yi'],
+ $this->addRectangle ($conf['Xi'], $conf['Yi'], $conf['Xf'],
+ $conf['Yf'], '', null, $this->orientacion);
+ $this->addLine($conf['linea1']['Xi'], $conf['linea1']['Yi'],
$conf['linea1']['Xf'], $conf['linea1']['Yf'], '', null,
- $this->_orientacion);
- $this->_pdf->addLine($conf['linea2']['Xi'], $conf['linea2']['Yi'],
+ $this->orientacion);
+ $this->addLine($conf['linea2']['Xi'], $conf['linea2']['Yi'],
$conf['linea2']['Xf'], $conf['linea2']['Yf'], '', null,
- $this->_orientacion);
+ $this->orientacion);
}
/**
function _addTitle() {
$conf = $this->_config['titulo'];
if ($this->titulo) {
- $tmp = $this->_pdf->strlen($this->titulo, $conf);
- $tmp2 = $this->_pdf->getWidth($this->_orientacion);
+ $tmp = $this->strlen($this->titulo, $conf);
+ $tmp2 = $this->getWidth($this->orientacion);
if ($tmp >= $tmp2) {
- $this->titulo = $this->_pdf->wrapLine ($this->titulo, $tmp2,
+ $this->titulo = $this->wrapLine ($this->titulo, $tmp2,
$conf);
- $tmp = $this->_pdf->strlen($this->titulo, $conf);
+ $tmp = $this->strlen($this->titulo, $conf);
}
$init = ($tmp2 - $tmp) / 2;
- $this->_pdf->addText($init, $conf['Y'], $this->titulo,
- $conf, null, $this->_orientacion);
+ $this->addText($init, $conf['Y'], $this->titulo,
+ $conf, null, $this->orientacion);
}
}
function _addSubTitle() {
$conf = $this->_config['subtitulo'];
if ($this->subtitulo) {
- $tmp = $this->_pdf->strlen($this->subtitulo, $conf);
- $tmp2 = $this->_pdf->getWidth($this->_orientacion);
+ $tmp = $this->strlen($this->subtitulo, $conf);
+ $tmp2 = $this->getWidth($this->orientacion);
if ($tmp >= $tmp2) {
- $this->subtitulo = $this->_pdf->wrapLine ($this->subtitulo, $tmp2,
+ $this->subtitulo = $this->wrapLine ($this->subtitulo, $tmp2,
$conf);
- $tmp = $this->_pdf->strlen($this->subtitulo, $conf);
+ $tmp = $this->strlen($this->subtitulo, $conf);
}
$init = ($tmp2 - $tmp) / 2;
- $this->_pdf->addText($init, $conf['Y'], $this->subtitulo,
- $conf, null, $this->_orientacion);
+ $this->addText($init, $conf['Y'], $this->subtitulo,
+ $conf, null, $this->orientacion);
}
}
/**
- * Funcion que agrega la informacion del marco a la pagina actual.
+ * Funcion que agrega el encabezado a la pagina actual.
*
* @param bool $title Muetra o no el titulo.
* @param bool $subtitle Muestra o no el subtitulo.
*
* @return void
- * @access public
+ * @access protected
*/
- function buildPage($title = true, $subtitle = true) {
+ function _buildHeader($title = true, $subtitle = true) {
$this->_addLogo();
$this->_addSeccion();
$this->_addSubseccion();
}
/**
- * Funcion que devuelve el espacio dispobible en una pagina.
- *
- * @param int $pagina Numero de pagina.
+ * Funcion que agrega el contenido al PDF.
*
- * @return int
+ * @return void
* @access protected
*/
- function _getAvailableSpace($pagina) {
- if ($pagina === 1 && $this->titulo && $this->subtitulo) {
- return $this->_config['contenido']['Y'];
+ function _buildContent() {
+ if ($this->_contenido) {
+ foreach ($this->_contenido as $cont) {
+ $cont->toPDF($this);
+ //MECON_PDF_Marco se pasa por referencia para que se agregen las
+ //paginas a medida que se van necesitando. Esto permite que varie el
+ //tipo de contenido que se agrega.
+ }
}
- else {
- return $this->_config['titulo']['Y'];
+ }
+
+ /**
+ * Funcion que se encarga de transformar la informacion para que se genere
+ * el archivo pdf.
+ *
+ * @return pdffile Archivo PDF.
+ * @access public
+ */
+ function toPDF() {
+ $this->newPage($this->tamanio);
+ $this->_buildContent();
+ if ($this->getPages()) {
+ $t = true;
+ foreach ($this->getPages() as $page) {
+ $this->_pagina_actual = $page;
+
+ $sec = $this->seccion;
+ $subsec = $this->subseccion;
+
+ if (@$this->_excepciones[$this->numPage($page)]['seccion']) {
+ $this->seccion =
+ $this->_excepciones[$this->numPage($page)]['seccion'];
+ }
+
+ if (@$this->_excepciones[$this->numPage($page)]['subseccion']) {
+ $this->subseccion =
+ $this->_excepciones[$this->numPage($page)]['subseccion'];
+ }
+
+ if (@!$this->_excepciones[$this->numPage($page)]['nova']) {
+ $this->_buildHeader($t, $t);
+ }
+ $t = false;
+
+ $this->seccion = $sec;
+ $this->subseccion = $subsec;
+ }
+ return parent::toPDF();
}
}
+ /**
+ * Funcion que pemite agregar contenido al PDF.
+ *
+ * @param mixed $contenido Objeto contenido que se agrega.
+ * @param bool $separador Indicacion si hay que agregar un separador.
+ *
+ * @return void
+ * @access public
+ */
+ function addContent($contenido, $separador = true) {
+ if ($separador && $this->getPages()) {
+ //@TODO Agregar el separador por defecto.
+ //$this->contenido[] = $separador_defecto
+ }
+ $this->_contenido[] = $contenido;
+ }
}
?>
\ No newline at end of file
$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.
*/
'encabezado' => array ( //Encabezado de cada pagina
'Xi' => 0,
'Xf' => 530,
- 'Yi' => 657,
- 'Yf' => 700,
+ 'Yi' => 657,
+ 'Yf' => 700, //Siempre debe representar la altura maxima de la pagina
'logo' => array (
'X' => 7,
'Y' => 665,
'height' => 13
),
//}}}
- //Contenido {{{
- 'contenido' => array (
- 'Y' => 580,
- ),
- 'celda_cabecera' => array (
- 'alto_linea' => 13,
- 'font' => 'Helvetica-Bold',
- 'height' => 11,
- 'fillcolor' => array (
- 'red' => '1',
- 'blue' => '1',
- 'green' => '1',
- ),
- 'fill' => array (
- 'mode' => 'fill+stroke',
- 'fillcolor' => array (
- 'red' => '.3',
- 'blue' => '.3',
- 'green' => '.3',
- ),
- 'strokecolor' => array (
- 'red' => '0',
- 'blue' => '0',
- 'green' => '0'
- ),
- ),
- ),
- 'celda_titulo' => array (
- 'alto_linea' => 13,
- 'font' => 'Helvetica-Bold',
- 'height' => 11,
- 'fillcolor' => array (
- 'red' => '0',
- 'blue' => '0',
- 'green' => '0',
- ),
- 'fill' => array (
- 'mode' => 'fill+stroke',
- 'fillcolor' => array (
- 'red' => '.7',
- 'blue' => '.7',
- 'green' => '.7',
- ),
- 'strokecolor' => array (
- 'red' => '0',
- 'blue' => '0',
- 'green' => '0'
- ),
- ),
- ),
- 'celda_comun' => array (
- 'alto_linea' => 10,
- 'font' => 'Helvetica-Bold',
- 'height' => 8,
- 'fillcolor' => array (
- 'red' => '0',
- 'blue' => '0',
- 'green' => '0',
- ),
- ),
- //}}}
),
//}}}
//LandScape {{{
'height' => 13,
),
//}}}
- //Contenido {{{
- 'contenido' => array (
- 'Y' => 422,
- ),
- 'celda_cabecera' => array (
- 'alto_linea' => 13,
- 'font' => 'Helvetica-Bold',
- 'height' => 11,
- 'fillcolor' => array (
- 'red' => '1',
- 'blue' => '1',
- 'green' => '1',
- ),
- 'fill' => array (
- 'mode' => 'fill+stroke',
- 'fillcolor' => array (
- 'red' => '.3',
- 'blue' => '.3',
- 'green' => '.3',
- ),
- 'strokecolor' => array (
- 'red' => '0',
- 'blue' => '0',
- 'green' => '0'
- ),
- ),
- ),
- 'celda_titulo' => array (
- 'alto_linea' => 13,
- 'font' => 'Helvetica-Bold',
- 'height' => 11,
- 'fillcolor' => array (
- 'red' => '0',
- 'blue' => '0',
- 'green' => '0',
- ),
- 'fill' => array (
- 'mode' => 'fill+stroke',
- 'fillcolor' => array (
- 'red' => '.7',
- 'blue' => '.7',
- 'green' => '.7',
- ),
- 'strokecolor' => array (
- 'red' => '0',
- 'blue' => '0',
- 'green' => '0'
- ),
- ),
- ),
- 'celda_comun' => array (
- 'alto_linea' => 10,
- 'font' => 'Helvetica-Bold',
- 'height' => 8,
- 'fillcolor' => array (
- 'red' => '0',
- 'blue' => '0',
- 'green' => '0',
- ),
- ),
- //}}}
),
//}}}
),
--- /dev/null
+<?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: jue nov 6 16:13:38 ART 2003
+Autor: Martin Marrese <mmarre@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id$
+-----------------------------------------------------------------------------*/
+
+require_once 'MECON/PDF/Separador.php';
+
+/**
+ * Manejo de los saltos de pagina.
+ */
+class MECON_PDF_SaltoPagina extends MECON_PDF_Separador {
+
+ /**
+ * Class Constructor
+ *
+ * @return void
+ * @access public
+ */
+ function MECON_PDF_SaltoPagina() {
+ $this->MECON_PDF_Separador();
+ }
+
+ /**
+ * Funcion que agrega el salto de pagina al PDF
+ *
+ * @param &Object $MARCO MECON_PDF_Marco.
+ *
+ * @return void
+ * @access public
+ */
+ function toPDF(&$MARCO) {
+ $MARCO->espacioDisponible -= 0;
+ parent::toPDF($MARCO);
+ }
+}
+?>
\ No newline at end of file
--- /dev/null
+<?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: jue nov 6 16:13:38 ART 2003
+Autor: Martin Marrese <mmarre@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id$
+-----------------------------------------------------------------------------*/
+
+require_once 'MECON/PDF/Contenido.php';
+
+/**
+ * Manejo de los separadores del contenido de los PDF's.
+ * @TODO Por ahora es muy basica y lo unico que agrega es un espacio en blanco
+ * (Disminuye el espacio disponible en MECON_PDF_Marco para el contenido), en un
+ * futuro la idea es que pueda variarse el separador.
+ */
+class MECON_PDF_Separador extends MECON_PDF_Contenido {
+
+ /**
+ * Altura de separacion por defecto
+ * @var $separacion
+ * @access protected
+ */
+ $_alto;
+
+ /**
+ * Class Constructor
+ *
+ * @param int $altura Altura del separador.
+ *
+ * @return void
+ * @access public
+ */
+ function MECON_PDF_Separador($altura = 27) {
+ $this->_alto = $altura;
+ }
+
+ /**
+ * Funcion que agrega el separador al PDF
+ *
+ * @param &Object $MARCO MECON_PDF_Marco.
+ *
+ * @return void
+ * @access public
+ */
+ function toPDF(&$MARCO) {
+ $MARCO->espacioDisponible -= $this->_alto;
+ }
+}
+?>
\ No newline at end of file
$Id$
-----------------------------------------------------------------------------*/
-require_once 'MECON/PDF/Marco.php';
+require_once 'MECON/PDF/Contenido.php';
/**
* Libreria que permite agregar una tabla a un pdf.
*/
-class MECON_PDF_Tabla extends MECON_PDF_Marco {
-
+class MECON_PDF_Tabla extends MECON_PDF_Contenido {
+
+ /**
+ * Configuracion
+ * @var array $config
+ * @access protected
+ */
+ var $_config;
+
+ /**
+ * Objeto MECON_HTML_Tabla.
+ * @var &Object $tabla MECON_HTML_Tabla
+ * @access protected
+ */
+ var $_tabla;
+
+ /**
+ * Objeto MECON_PDF_Marco
+ * @var &Object $marco
+ * @access protected
+ */
+ var $_marco;
+
/**
- * Funcion que envia el archivo a pantalla (para que el usuario haga un
- * download)
+ * Class Constructor
+ *
+ * @param &Object $TABLA MECON_HTML_Tabla
*
- * @return string
+ * @return void
* @access public
*/
- function display() {
+ function MECON_PDF_Tabla(&$TABLA) {
+ $this->_tabla =& $TABLA;
+ $this->_config = include 'MECON/PDF/Tabla/medidas.php';
+ }
+
+ /**
+ * Funcion que agrega el contenido de la tabla que se este utilizando al
+ * PDF.
+ *
+ * @param &Object $MARCO MECON_PDF_Marco
+ *
+ * @return void
+ * @access public
+ */
+ function toPDF(&$MARCO) {
+ $this->_marco =& $MARCO;
$this->_agregarContenido();
-
- //Agrego los encabezados
- $t = true;
- foreach ($this->_pdf->getPages() as $page) {
- $this->_pdf->_pagina_actual = $page;
- $this->buildPage($t, $t);
- $t = false;
- }
-
- $this->_pdf->display();
}
/**
*/
function _obtenerAlineacionTexto($row, $col, $texto, $attr, $estilo) {
- $at = $this->getCellAttributes($row, $col);
+ $at = $this->_tabla->getCellAttributes($row, $col);
if (@$at['align'] == 'center') {
- $tam = $this->_pdf->strlen($texto, $estilo);
+ $tam = $this->_marco->strlen($texto, $estilo);
$init = $attr[$col] + ($attr[$col+1] - $attr[$col] - $tam) / 2;
}
elseif (@$at['align'] == 'right') {
- $tam = $this->_pdf->strlen($texto, $estilo);
+ $tam = $this->_marco->strlen($texto, $estilo);
$init = $attr[$col+1] - $tam + 1;
}
else {
* @access protected
*/
function _obtenerEstiloCelda($row, $col) {
- $clase = $this->getCellAttributes($row, $col);
+ $clase = $this->_tabla->getCellAttributes($row, $col);
if (@$clase['cabecera'] || @$clase['oscura']) {
$estilo = $this->_config['celda_cabecera'];
}
* @access protected
*/
function _obtenerAnchoColumnas() {
- $ancho_pagina = $this->_pdf->getWidth($this->_orientacion);
- for ($i=0; $i<$this->getColCount(); $i++ ) {
- $tmp = $this->getCellAttributes(0,$i);
+ $ancho_pagina = $this->_marco->getWidth($this->_marco->orientacion);
+ for ($i=0; $i<$this->_tabla->getColCount(); $i++ ) {
+ $tmp = $this->_tabla->getCellAttributes(0,$i);
if (is_null(@$tmp['width'])) {
die ('Todas las columnas deben tener asignado un ancho.');
}
* @access protected
*/
function _agregarContenido() {
- $this->_pdf->newPage($this->_tamanio);
- $alto = $this->_getAvailableSpace($this->_pdf->numPage());
+ $alto = $this->_marco->espacioDisponible;
+ if ($alto <= 0 ) {
+ $this->_marco->newPage($this->_marco->tamanio);
+ }
+ //\@TODO Aca antes de crear una nueva pagina utilizar la que ya existe
$attr2 = $this->_obtenerAnchoColumnas();
- for ($i = 0; $i < $this->getRowCount(); $i++) {
+ for ($i = 0; $i < $this->_tabla->getRowCount(); $i++) {
$max = 0;
- for ($j = 0; $j < $this->getColCount(); $j++) {
+ for ($j = 0; $j < $this->_tabla->getColCount(); $j++) {
$estilo = $this->_obtenerEstiloCelda($i, $j);
- $txt = $this->_pdf->wordWrap($this->getCellContents($i,$j),
+ $txt = $this->_marco->wordWrap($this->_tabla->getCellContents($i,$j),
$attr2[$j+1] - $attr2[$j], $estilo);
$txtt[$j] = $txt; //Esto es para no hacer el wordWrap siempre
$max = max($estilo['alto_linea'] * count($txt), $max);
$rep = array ();
- $rep = $this->getCellAttributes($i, $j);
+ $rep = $this->_tabla->getCellAttributes($i, $j);
if (@$rep['cabecera'] || @$rep['titulo']) {
$repetir[$i][$j] = $txt;
$repetir[$i]['max'] = $max;
}
}
- if ($alto < 0) {
- $this->_pdf->newPage($this->_tamanio);
- $alto = $this->_getAvailableSpace($this->_pdf->numPage());
+ if ($alto <= 0) {
+ $this->_marco->newPage($this->_marco->tamanio);
+ $alto = $this->_marco->espacioDisponible;
foreach ($repetir as $ii => $value) {
$alto -= $repetir[$ii]['max'];
- for ($jj = 0; $jj < $this->getColCount(); $jj++) {
+ for ($jj = 0; $jj < $this->_tabla->getColCount(); $jj++) {
$estilo = $this->_obtenerEstiloCelda($ii, $jj);
- $this->_pdf->addRectangle($attr2[$jj], $alto,
+ $this->_marco->addRectangle($attr2[$jj], $alto,
$attr2[$jj+1], $alto+$repetir[$ii]['max'],
- @$estilo['fill'], null, $this->_orientacion);
+ @$estilo['fill'], null, $this->_marco->orientacion);
$alto1 = $alto + $repetir[$ii]['max'];
foreach ($repetir[$ii][$jj] as $t) {
$init = $this->_obtenerAlineacionTexto($ii, $jj, $t, $attr2,
$estilo);
- $this->_pdf->addText($init, $alto1 + 2,
- $t, $estilo, null, $this->_orientacion);
+ $this->_marco->addText($init, $alto1 + 2,
+ $t, $estilo, null, $this->_marco->orientacion);
}
}
}
}
$alto -= $max;
- for ($j = 0; $j < $this->getColCount(); $j++) {
+ for ($j = 0; $j < $this->_tabla->getColCount(); $j++) {
$estilo = $this->_obtenerEstiloCelda($i, $j);
- $this->_pdf->addRectangle($attr2[$j], $alto,
+ $this->_marco->addRectangle($attr2[$j], $alto,
$attr2[$j+1], $alto+$max, @$estilo['fill'], null,
- $this->_orientacion);
+ $this->_marco->orientacion);
$alto1 = $alto + $max;
foreach ($txtt[$j] as $t) {
$init = $this->_obtenerAlineacionTexto($i, $j, $t, $attr2,
$estilo);
- $this->_pdf->addText($init, $alto1 + 2,
- $t, $estilo, null, $this->_orientacion);
+ $this->_marco->addText($init, $alto1 + 2,
+ $t, $estilo, null, $this->_marco->orientacion);
}
}
}
+ $this->_marco->espacioDisponible = $alto;
}
}
?>
\ No newline at end of file
--- /dev/null
+<?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: jue nov 6 17:05:20 ART 2003
+Autor: Martin Marrese <mmarre@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id$
+-----------------------------------------------------------------------------*/
+
+/**
+ * Connfiguracion de las celdas de la tabla
+ */
+return array (
+ //CELDA CABECERA {{{
+ 'celda_cabecera' => array (
+ 'alto_linea' => 13,
+ 'font' => 'Helvetica-Bold',
+ 'height' => 11,
+ 'fillcolor' => array (
+ 'red' => '1',
+ 'blue' => '1',
+ 'green' => '1',
+ ),
+ 'fill' => array (
+ 'mode' => 'fill+stroke',
+ 'fillcolor' => array (
+ 'red' => '.3',
+ 'blue' => '.3',
+ 'green' => '.3',
+ ),
+ 'strokecolor' => array (
+ 'red' => '0',
+ 'blue' => '0',
+ 'green' => '0'
+ ),
+ ),
+ ),
+ //}}}
+ //CELDA TITULO {{{
+ 'celda_titulo' => array (
+ 'alto_linea' => 13,
+ 'font' => 'Helvetica-Bold',
+ 'height' => 11,
+ 'fillcolor' => array (
+ 'red' => '0',
+ 'blue' => '0',
+ 'green' => '0',
+ ),
+ 'fill' => array (
+ 'mode' => 'fill+stroke',
+ 'fillcolor' => array (
+ 'red' => '.7',
+ 'blue' => '.7',
+ 'green' => '.7',
+ ),
+ 'strokecolor' => array (
+ 'red' => '0',
+ 'blue' => '0',
+ 'green' => '0'
+ ),
+ ),
+ ),
+ //}}}
+ //CELDA COMUN {{{
+ 'celda_comun' => array (
+ 'alto_linea' => 10,
+ 'font' => 'Helvetica-Bold',
+ 'height' => 8,
+ 'fillcolor' => array (
+ 'red' => '0',
+ 'blue' => '0',
+ 'green' => '0',
+ ),
+ ),
+ //}}}
+ );
+?>
--- /dev/null
+<?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: jue nov 6 16:13:38 ART 2003
+Autor: Martin Marrese <mmarre@mecon.gov.ar>
+-------------------------------------------------------------------------------
+$Id$
+-----------------------------------------------------------------------------*/
+
+require_once 'MECON/PDF/Contenido.php';
+
+/**
+ * Libreria de texto en PDF.
+ */
+class MECON_PDF_Texto extends MECON_PDF_Contenido {
+
+}
+?>
\ No newline at end of file
-------------------------------------------------------------------------------
$Id$
-----------------------------------------------------------------------------*/
+/**
+ * Este archivo contiene las dimensiones del espacio utilizable de los
+ * diferentes tipos de hojas.
+
+ Y ^
+ |
+ Yf- +------------+
+ | | |
+ | | |
+ | | |
+ | | |
+ | | |
+ | | |
+ | | |
+ Yi- +------------+
+ -+--|------------|---------->
+ | Xi Xf X
+ */
+
/**
* Medidas para cada formato de pagina.
--- /dev/null
+#!/bin/sh
+wget -O pdf.pdf http://bal747f.mecon.ar/~mmarrese/meconlib/test/PDF/test.php;gv pdf.pdf
--- /dev/null
+<?php
+
+require_once 'MECON/general.php';
+prepend_include_path('/home/mmarrese/public_html/meconlib/lib/');
+
+require_once 'MECON/HTML/Tabla.php';
+require_once 'MECON/PDF/Marco.php';
+require_once 'MECON/PDF/Tabla.php';
+
+$TABLA =& new MECON_HTML_Tabla();
+
+$TABLA->addRow(array ('1erCabecera', '2daCabecera para que la corete',
+ '3erCabecera'), 'cabecera');
+$TABLA->addRow(array ('1erColumna', '2daColumna para que la corete',
+ '3erColumna'), 'clara');
+for ($i=0; $i<60; $i++) {
+ if ($i == 50) {
+ $TABLA->addRow(array ('1erColumna para gonzalo que lo mira por tv desde su casa en ayacucho 1593. Aunque ahora que lo pienso me estoy equivocando', '2daColumna 1erColumna para gonzalo que lo mira por tv desde su casa en ayacucho 1593. Aunque ahora que lo pienso me estoy equivocando FILA 50', '3erColumna1erColumna para gonzalo que lo mira por tv desde su casa en ayacucho 1593. Aunque ahora que lo pienso me estoy equivocando'), 'comun');
+ }
+ elseif ($i == 30) {
+ $TABLA->addRow(array ('Esto es para probar', 'como repite las celdas',
+ 'MECON_PDF_Tabla'), 'titulo');
+ }
+ else {
+ $TABLA->addRow(array ('Fila: '.$i.'Col: 1 ', 'Fila: '.$i.'Col: 2', 'Fila: '.$i.'Col: 3'), 'comun');
+ }
+}
+$TABLA->updateColAttributes(0, 'width="50%"');
+$TABLA->updateColAttributes(1, 'width="25%"');
+$TABLA->updateColAttributes(2, 'width="35%"');
+$TABLA->updateCellAttributes(2,0, 'align="left"');
+$TABLA->updateCellAttributes(2,1, 'align="center"');
+$TABLA->updateCellAttributes(2,2, 'align="right"');
+
+$PDF_MARCO =& new MECON_PDF_Marco ('a4', 'portrait');
+$PDF_MARCO->seccion = 'Prueba de la libreria de PDF\'s';
+$PDF_MARCO->titulo = 'Alberto Giordano';
+$PDF_MARCO->subtitulo = 'Filosofo Estilista, guacho pulenta si los hay';
+
+$PDF_MARCO->addContent(new MECON_PDF_Tabla ($TABLA), false);
+
+$PDF_MARCO->display();
+
+?>