*/
class MECON_PDF {
+ /**
+ * Orientacion (portrait o landscape).
+ * @var sting $orientacion
+ * @access public
+ */
+ var $orientacion = "portrait";
+
+ /**
+ *
+ * Orientacion cambiada, indica la orientacion de la pagina cuando es
+ * distinto al comun
+ * @var array $orientacion_distinta
+ * @access protected
+ */
+ var $_orientacion_distinta = array();
+
/**
* Configuracion
* @var arary $config
* @access protected
*/
- var $config;
+ var $_config = array ();
/**
* Libreria externa.
* @var int $pdf
- * @access private
+ * @access protected
*/
var $_pdf;
* @var array $paginas
* @access private
*/
- var $_paginas;
+ var $_paginas = array();
/**
* Class constructor.
*
* @param string $tam Tipo de hoja
+ * @param string $ori Orientacion de las hojas (portrait o landscape).
*
* @return void
* @access public
*/
- function MECON_PDF($tam = "a4")
+ function MECON_PDF($tam = "a4", $ori = "portrait")
{
+ $this->orientacion = $ori;
$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];
}
/**
* Permite agregar nuevas paginas al pdf que se esta armando.
*
* @param string $pagina Tipo de pagina que se va a utilizar.
+ * @param string $orientacion Orientacion de la pagina en particular.
*
* @return void
* @access public
*/
- function newPage($pagina = "a4")
+ function newPage($pagina = "a4", $orientacion = null)
{
$this->_pagina_actual = $this->_pdf->new_page($pagina);
$this->_paginas[] = $this->_pagina_actual;
+ if(!is_null($orientacion) && $orientacion != $this->orientacion)
+ $this->_orientacion_distinta[$this->numPage()] = $orientacion;
+ }
+
+ /**
+ * Funcion que retorna la orientacion de la pagina indicada.
+ * Si no se indica, toma la orientacion de la ultima pagina.
+ *
+ * @param int $pagina Numero de la pagina.
+ *
+ * @access public
+ * @return int
+ */
+ function getOrientation($pagina = null)
+ {
+ if(is_null($pagina))
+ $pagina = $this->numPage();
+
+ if(isset($this->_orientacion_distinta[$pagina]))
+ return $this->_orientacion_distinta[$pagina];
+ else
+ return $this->orientacion;
}
/**
* @return void
* @access public
*/
- function addText($X, $Y, $texto, $estilo = '', $pag = null, $transformacion =
- '')
- {
+ function addText($X, $Y, $texto, $estilo = '', $pag = null, $transformacion
+ = null) {
$x = $X;
$y = $Y;
+ if(is_null($transformacion))
+ $transformacion = $this->getOrientation($pag);
switch (strtolower($transformacion)) {
case 'portrait':
$X = $this->_portraitX($x,$y);
case 'landscape':
$X = $this->_landscapeX($x,$y);
$Y = $this->_landscapeY($x,$y);
- $estilo['rotation'] = 90;
+ @$estilo['rotation'] += 90;
break;
}
$this->_pdf->draw_text($X, $Y, $texto, $this->refPage($pag), $estilo);
* @access public
*/
function addRectangle($Xi, $Yi, $Xf, $Yf, $estilo = '', $pag = null,
- $transformacion = 'portrait')
+ $transformacion = null)
{
$xi = $Xi;
$yi = $Yi;
$xf = $Xf;
$yf = $Yf;
+ if(is_null($transformacion))
+ $transformacion = $this->getOrientation($pag);
switch (strtolower($transformacion)) {
case 'portrait':
$Xi = $this->_portraitX($xi,$yi);
* @access public
*/
function addLine($Xi, $Yi, $Xf, $Yf, $estilo = '', $pag = null,
- $transformacion = 'portrait')
+ $transformacion = null)
{
$xi = $Xi;
$yi = $Yi;
$xf = $Xf;
$yf = $Yf;
+ if(is_null($transformacion))
+ $transformacion = $this->getOrientation($pag);
switch (strtolower($transformacion)) {
case 'portrait':
$Xi = $this->_portraitX($xi,$yi);
* @access public
*/
function addImage($archivo, $X, $Y, $pag = null, $formato = null,
- $transformacion = 'portrait') {
+ $transformacion = null) {
$x = $X;
$y = $Y;
+ if(is_null($transformacion))
+ $transformacion = $this->getOrientation($pag);
switch (strtolower($transformacion)) {
case 'portrait':
$X = $this->_portraitX($x,$y);
* @return int
* @access public
*/
- function getWidth($orientacion = 'portrait')
+ function getWidth($pagina = null, $orientacion = null)
{
- switch (strtolower($orientacion)) {
+ if(is_null($orientacion))
+ $orientacion = $this->getOrientation($pagina);
+ 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;
* @return int
* @access public
*/
- function getHeight($orientacion = 'portrait')
+ function getHeight($pagina = null, $orientacion = null)
{
- switch (strtolower($orientacion)) {
+ if(is_null($orientacion))
+ $orientacion = $this->getOrientation($pagina);
+ 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