<?php
require('../fpdf/fpdf.php');
require('rotation.php');
define('FPDF_FONTPATH','../fpdf/font/');
if (isset($_GET["foto"])) {
$foto = urldecode($_GET["foto"]);
}
else {
$foto = "../2002/fotos/2002V087.jpg";
}
if (isset($_GET["formato"])) {
$formato = $_GET["formato"];
}
else {
$formato = "V";
}
if (isset($_GET["pag"])) {
$pag = $_GET["pag"];
}
else {
$pag = "A4";
}
if ($pag == "A6")
$a = array (105.0, 148.5);
else
$a = $pag;
if ($formato == "H")
$formatoPdf = ($pag == "A6" || $pag == "A4") ? "L" : "P";
else
$formatoPdf = ($pag == "A6" || $pag == "A4") ? "P" : "L";
//class PDF extends FPDF {
class PDF extends PDF_Rotate {
function RotatedText($x, $y, $txt, $angle) {
//Text rotated around its origin
$this->Rotate($angle,$x,$y);
$this->Text($x,$y,$txt);
$this->Rotate(0);
}
function ponImagen($foto, $x, $y, $ancho, $alto, $tipo, $margen) {
$x0 = $x + $margen;
$y0 = $y + $margen;
$w0 = $ancho - ($margen * 2);
$h0 = $alto - ($margen * 2);
$this->Image($foto, $x0, $y0, $w0, $h0, $tipo);
}
function ponLineas($x, $y, $ancho, $alto, $margen, $foto) {
$this->SetFont('Arial', '', 8);
$this->SetLineWidth(.1);
// posición del texto
$lineaL = array(5, 100);
$lineaP = array(100, 143.5);
$linea = array(true => $lineaL, false => $lineaP);
list($x0, $y0) = $linea[$ancho > $alto];
if ($ancho > $alto)
$this->Text($x0 + $x, $y0 + $y, $foto);
else
$this->RotatedText($x0 + $x, $y0 + $y, $foto, 90);
// Línea inferior alargada de la postal
$lineaL = array(5, 95, 143.5, 95);
$lineaP = array(95, 5, 95, 143.5);
$linea = array(true => $lineaL, false => $lineaP);
list($x0, $y0, $x1, $y1) = $linea[$ancho > $alto];
$this->Line($x0 + $x, $y0 + $y, $x1 + $x, $y1 + $y);
// Línea divisoria
$lineaL = array(74, 5, 74, 90);
$lineaP = array(5, 74, 90, 74);
$linea = array(true => $lineaL, false => $lineaP);
list($x0, $y0, $x1, $y1) = $linea[$ancho > $alto];
$this->Line($x0 + $x, $y0 + $y, $x1 + $x, $y1 + $y);
// Pequeña línea inferior derecha y baja de la postal
$lineaL = array(90, 90, 143.5, 90);
$lineaP = array(90, 5, 90, 50);
$linea = array(true => $lineaL, false => $lineaP);
list($x0, $y0, $x1, $y1) = $linea[$ancho > $alto];
$this->Line($x0 + $x, $y0 + $y, $x1 + $x, $y1 + $y);
// Pequeña línea inferior (un poco hacia arriba) derecha y baja de la postal
$lineaL = array(90, 80, 143.5, 80);
$lineaP = array(80, 5, 80, 50);
$linea = array(true => $lineaL, false => $lineaP);
list($x0, $y0, $x1, $y1) = $linea[$ancho > $alto];
$this->Line($x0 + $x, $y0 + $y, $x1 + $x, $y1 + $y);
// Otra pequeña línea inferior (un poco hacia arriba) derecha y baja de la postal
$lineaL = array(90, 77, 143.5, 77);
$lineaP = array(77, 5, 77, 50);
$linea = array(true => $lineaL, false => $lineaP);
list($x0, $y0, $x1, $y1) = $linea[$ancho > $alto];
$this->Line($x0 + $x, $y0 + $y, $x1 + $x, $y1 + $y);
// Línea mayor (un poco hacia arriba) derecha
$lineaL = array(78, 70, 143.5, 70);
$lineaP = array(70, 5, 70, 70);
$linea = array(true => $lineaL, false => $lineaP);
list($x0, $y0, $x1, $y1) = $linea[$ancho > $alto];
$this->Line($x0 + $x, $y0 + $y, $x1 + $x, $y1 + $y);
// Otra línea mayor (un poco hacia arriba) derecha
$lineaL = array(78, 60, 143.5, 60);
$lineaP = array(60, 5, 60, 70);
$linea = array(true => $lineaL, false => $lineaP);
list($x0, $y0, $x1, $y1) = $linea[$ancho > $alto];
$this->Line($x0 + $x, $y0 + $y, $x1 + $x, $y1 + $y);
// Primera línea mayor (un poco hacia arriba) derecha
$lineaL = array(78, 50, 143.5, 50);
$lineaP = array(50, 5, 50, 70);
$linea = array(true => $lineaL, false => $lineaP);
list($x0, $y0, $x1, $y1) = $linea[$ancho > $alto];
$this->Line($x0 + $x, $y0 + $y, $x1 + $x, $y1 + $y);
// Recuadro para el sello
$lineaL = array(123.5, 5, 20, 25);
$lineaP = array(5, 5, 25, 20);
$linea = array(true => $lineaL, false => $lineaP);
list($x0, $y0, $x1, $y1) = $linea[$ancho > $alto];
$this->Rect($x0 + $x, $y0 + $y, $x1, $y1, "");
}
}
//$a = array (105.0, 148.5);
$pdf=new PDF($formatoPdf, 'mm', $a);
$pdf->AddPage();
switch ($pag) {
case "A6":
if ($formatoPdf == "P") {
$pdf->ponImagen($foto, 0, 0, 105, 148.5, 'JPEG', 5);
}
else {
$pdf->ponImagen($foto, 0, 0, 148.5, 105, 'JPEG', 5);
}
break;
case "A5":
if ($formatoPdf == "L") {
$pdf->Image($foto, 5, 5, 95, 138, 'JPEG');
$pdf->Image($foto, 110, 5, 95, 138, 'JPEG');
}
else {
$pdf->Image($foto, 5, 5, 138, 95, 'JPEG');
$pdf->Image($foto, 5, 110, 138, 95, 'JPEG');
}
break;
case "A4":
if ($formatoPdf == "P") {
$pdf->Image($foto, 5, 5, 95, 138, 'JPEG');
$pdf->Image($foto, 110, 5, 95, 138, 'JPEG');
$pdf->Image($foto, 5, 153, 95, 138, 'JPEG');
$pdf->Image($foto, 110, 153, 95, 138, 'JPEG');
}
else {
$pdf->Image($foto, 5, 5, 138, 95, 'JPEG');
$pdf->Image($foto, 5, 110, 138, 95, 'JPEG');
$pdf->Image($foto, 153, 5, 138, 95, 'JPEG');
$pdf->Image($foto, 153, 110, 138, 95, 'JPEG');
}
break;
case "A3":
if ($formatoPdf == "L") {
$pdf->Image($foto, 5, 5, 95, 138, 'JPEG');
$pdf->Image($foto, 110, 5, 95, 138, 'JPEG');
$pdf->Image($foto, 5, 153, 95, 138, 'JPEG');
$pdf->Image($foto, 110, 153, 95, 138, 'JPEG');
$pdf->Image($foto, 215, 5, 95, 138, 'JPEG');
$pdf->Image($foto, 320, 5, 95, 138, 'JPEG');
$pdf->Image($foto, 215, 153, 95, 138, 'JPEG');
$pdf->Image($foto, 320, 153, 95, 138, 'JPEG');
}
else {
$pdf->Image($foto, 5, 5, 138, 95, 'JPEG');
$pdf->Image($foto, 5, 110, 138, 95, 'JPEG');
$pdf->Image($foto, 153, 5, 138, 95, 'JPEG');
$pdf->Image($foto, 153, 110, 138, 95, 'JPEG');
$pdf->Image($foto, 5, 215, 138, 95, 'JPEG');
$pdf->Image($foto, 5, 320, 138, 95, 'JPEG');
$pdf->Image($foto, 153, 215, 138, 95, 'JPEG');
$pdf->Image($foto, 153, 320, 138, 95, 'JPEG');
}
break;
}
$pdf->AddPage();
switch ($pag) {
case "A6":
if ($formatoPdf == "P") {
$pdf->ponLineas(0, 0, 105, 148.5, 5, $foto);
}
else {
$pdf->ponLineas(0, 0, 148.5, 105, 5, $foto);
}
break;
case "A5":
if ($formatoPdf == "L") {
$pdf->ponLineas(0, 0, 105, 148.5, 5, $foto);
$pdf->ponLineas(105, 0, 105, 148.5, 5, $foto);
}
else {
$pdf->ponLineas(0, 0, 148.5, 105, 5, $foto);
$pdf->ponLineas(0, 105, 148.5, 105, 5, $foto);
}
break;
case "A4":
if ($formatoPdf == "P") {
$pdf->ponLineas(0, 0, 105, 148.5, 5, $foto);
$pdf->ponLineas(105, 0, 105, 148.5, 5, $foto);
$pdf->ponLineas(0, 148.5, 105, 148.5, 5, $foto);
$pdf->ponLineas(105, 148.5, 105, 148.5, 5, $foto);
}
else {
$pdf->ponLineas(0, 0, 148.5, 105, 5, $foto);
$pdf->ponLineas(0, 105, 148.5, 105, 5, $foto);
$pdf->ponLineas(148.5, 0, 148.5, 105, 5, $foto);
$pdf->ponLineas(148.5, 105, 148.5, 105, 5, $foto);
}
break;
case "A3":
if ($formatoPdf == "L") {
$pdf->ponLineas(0, 0, 105, 148.5, 5, $foto);
$pdf->ponLineas(105, 0, 105, 148.5, 5, $foto);
$pdf->ponLineas(0, 148.5, 105, 148.5, 5, $foto);
$pdf->ponLineas(105, 148.5, 105, 148.5, 5, $foto);
$pdf->ponLineas(210, 0, 105, 148.5, 5, $foto);
$pdf->ponLineas(315, 0, 105, 148.5, 5, $foto);
$pdf->ponLineas(210, 148.5, 105, 148.5, 5, $foto);
$pdf->ponLineas(315, 148.5, 105, 148.5, 5, $foto);
}
else {
$pdf->ponLineas(0, 0, 148.5, 105, 5, $foto);
$pdf->ponLineas(0, 105, 148.5, 105, 5, $foto);
$pdf->ponLineas(148.5, 0, 148.5, 105, 5, $foto);
$pdf->ponLineas(148.5, 105, 148.5, 105, 5, $foto);
$pdf->ponLineas(0, 210, 148.5, 105, 5, $foto);
$pdf->ponLineas(0, 315, 148.5, 105, 5, $foto);
$pdf->ponLineas(148.5, 210, 148.5, 105, 5, $foto);
$pdf->ponLineas(148.5, 315, 148.5, 105, 5, $foto);
}
break;
}
$pdf->Output();
?>