Revisión 518
Añadido por Manu Mora Gordillo hace más de 11 años
etiquetas-portatiles/trunk/backend.php | ||
---|---|---|
<?php
|
||
/*##############################################################################
|
||
# Project: Labels - Extremadura High Schools
|
||
# Purpose: Module to get groups of students
|
||
# Date: 24-Sep-2010.
|
||
# Ver.: 29-Sep-2010.
|
||
# Copyright: 2010 - Manu Mora Gordillo <manuito @nospam@ gmail.com>
|
||
#
|
||
# This program 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 3 of the License, or
|
||
# (at your option) any later version.
|
||
#
|
||
# This program 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
|
||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
#
|
||
############################################################################## */
|
||
|
||
$user="cn=".$_GET["userLDAP"].",ou=People,dc=instituto,dc=extremadura,dc=es";
|
||
|
||
$conex = ldap_connect("ldaps://".$_GET["hostLDAP"], 636);
|
||
if (!$conex){
|
||
$responce->msg = "noConnect";
|
||
die(json_encode($responce));
|
||
}
|
||
|
||
if (!@ldap_set_option($conex, LDAP_OPT_PROTOCOL_VERSION, 3)){
|
||
$responce->msg = "noProtocol";
|
||
die(json_encode($responce));
|
||
}
|
||
|
||
if (!@ldap_bind($conex, $user, $_GET["password"])){
|
||
$responce->msg = "noPassword";
|
||
die(json_encode($responce));
|
||
}
|
||
|
||
$dn = "ou=Group,dc=instituto,dc=extremadura,dc=es";
|
||
$fields = array("cn","grouptype","memberuid");
|
||
$sr=ldap_search($conex, $dn, "cn=*", $fields);
|
||
$result = ldap_get_entries($conex, $sr);
|
||
$groups = array();
|
||
|
||
for($i=0;$i<count($result);$i++){
|
||
if($result[$i]["grouptype"][0]=="school_class"){
|
||
$groups[] = $result[$i]["cn"][0];
|
||
}
|
||
}
|
||
|
||
if(count($groups)==0) die("noGroups");
|
||
|
||
sort($groups);
|
||
|
||
for($j=0;$j<count($groups);$j++)
|
||
$responce->groups[]=$groups[$j];
|
||
|
||
echo json_encode($responce);
|
||
?>
|
etiquetas-portatiles/trunk/index.php | ||
---|---|---|
<?php
|
||
/*##############################################################################
|
||
# Project: Labels - Extremadura High Schools
|
||
# Purpose: Module to generate labels of students for laptops
|
||
# Date: 24-Sep-2010.
|
||
# Ver.: 29-Sep-2010.
|
||
# Copyright: 2010 - Manu Mora Gordillo <manuito @nospam@ gmail.com>
|
||
#
|
||
# This program 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 3 of the License, or
|
||
# (at your option) any later version.
|
||
#
|
||
# This program 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
|
||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
#
|
||
############################################################################## */
|
||
|
||
if($_POST["action"]=="generate_labels"){
|
||
|
||
require('fpdf/fpdf.php');
|
||
include('qr/qr_img.php');
|
||
|
||
// Conectamos con LDAP
|
||
$user="cn=".$_POST["userLDAP"].",ou=People,dc=instituto,dc=extremadura,dc=es";
|
||
|
||
$conex=ldap_connect("ldaps://".$_POST["hostLDAP"], 636) or die ("No ha sido posible conectarse al servidor<br><br><input type='button' value='Volver' onClick='location.href=\"index.php\"'/>");
|
||
|
||
if (!@ldap_set_option($conex, LDAP_OPT_PROTOCOL_VERSION, 3))
|
||
die("Falló la configuracion de protocolo version 3<br><br><input type='button' value='Volver' onClick='location.href=\"index.php\"'/>");
|
||
|
||
if (!@ldap_bind($conex, $user, $_POST["password"]))
|
||
die("Upsss, falló la autenticación. Vuelve a intentarlo otra vez.<br><br><input type='button' value='Volver' onClick='location.href=\"index.php\"'/>");
|
||
|
||
// Obtenemos la info de LDAP
|
||
$dn = "ou=Group,dc=instituto,dc=extremadura,dc=es";
|
||
|
||
$filter="(|";
|
||
for($i=0;$i<count($_POST["classroomGroup"]);$i++){
|
||
$filter.="(cn=".$_POST["classroomGroup"][$i].")";
|
||
}
|
||
$filter.=")";
|
||
|
||
$fields = array("cn","grouptype","memberuid");
|
||
$sr=ldap_search($conex, $dn, $filter,$fields);
|
||
$groups = ldap_get_entries($conex, $sr);
|
||
|
||
$students = array();
|
||
for($i=0;$i<count($groups);$i++){
|
||
if($groups[$i]["grouptype"][0]=="school_class"){
|
||
for($j=0;$j<count($groups[$i]["memberuid"]);$j++){
|
||
if($groups[$i]["memberuid"][$j]!="")
|
||
$students[] = $groups[$i]["memberuid"][$j];
|
||
}
|
||
}
|
||
}
|
||
|
||
if(count($students)=="0")
|
||
die("No se han encontrado alumnos.<br><br><input type='button' value='Volver' onClick='location.href=\"index.php\"'/>");
|
||
|
||
sort($students);
|
||
|
||
$filter = "uid=*";
|
||
|
||
if($_POST["filter"]!=""){
|
||
// para que imprima la etiqueta en una posicion determinada de la pagina de etiquetas
|
||
//$offset = $_POST["offset"];
|
||
//$num_label = $offset - 1;
|
||
$array_filter = explode(",",$_POST["filter"]);
|
||
|
||
$filter = "(|";
|
||
for($r=0;$r<count($array_filter);$r++){
|
||
$filter.="(uid=*".trim($array_filter[$r])."*)";
|
||
}
|
||
$filter.= ")";
|
||
//$filter = $_POST["filter"]."*";
|
||
}
|
||
//echo ">>>>>>".$filter;
|
||
$dn = "ou=People,dc=instituto,dc=extremadura,dc=es";
|
||
$fields = array("uid","cn","employeenumber","jpegphoto");
|
||
$sr=ldap_search($conex, $dn, $filter, $fields);
|
||
//$sr=ldap_search($conex, $dn, "(|(uid=*marriaza*)(uid=*arodriguez*))", $fields);
|
||
$students_tmp = ldap_get_entries($conex, $sr);
|
||
|
||
// Llenar labels con posiciones vacias, para poner offset en etiquetas y comenzar a imprimir en una det. posicion
|
||
$offset = $_POST["offset"];
|
||
for ($j=1;$j<$offset;$j++)
|
||
$labels[] = array("cn"=>"","uid"=>"","nie"=>"","foto"=>"");
|
||
|
||
for($i=0;$i<count($students_tmp);$i++){
|
||
if(in_array($students_tmp[$i]["uid"][0],$students))
|
||
$labels[] = array("cn"=>$students_tmp[$i]["cn"][0],"uid"=>$students_tmp[$i]["uid"][0],"nie"=>$students_tmp[$i]["employeenumber"][0],"foto"=>$students_tmp[$i]["jpegphoto"][0]);
|
||
//echo ">>>>>>>>>>>>>>>>".$students_tmp[$i]["jpegphoto"][0];
|
||
}
|
||
|
||
// Creamos el PDF
|
||
$pdf=new FPDF();
|
||
$pdf->AddPage();
|
||
$pdf->SetFont('Arial','B',8);
|
||
|
||
$num_rows = $_POST["rows"];
|
||
$num_cols = $_POST["columns"];
|
||
|
||
$margenX = $_POST["xMargin"];
|
||
$margenY = $_POST["yMargin"];
|
||
$ancho = $_POST["width"];
|
||
$alto = $_POST["height"];
|
||
|
||
$QR_size=$_POST["qrSize"];
|
||
$photoWidth=$_POST["photoWidth"];
|
||
$photoHeight=$_POST["photoHeight"];
|
||
|
||
$num_label=0;
|
||
if(!file_exists("tmp")){
|
||
mkdir("tmp");
|
||
}
|
||
|
||
for($i=0;$i<$num_rows;$i++){
|
||
for($j=0;$j<$num_cols;$j++){
|
||
|
||
if(($num_label)==count($labels)){
|
||
$pdf->Output();
|
||
exit();
|
||
}
|
||
|
||
$x = $margenX + $j*$alto;
|
||
$y = $margenY + $i*$ancho;
|
||
|
||
// Para control de la posicion de inicio de impresion de las etiquetas
|
||
if ($labels[$num_label]["cn"] != "") {
|
||
$pdf->Text($x, $y+$QR_size+2, $labels[$num_label]["cn"]);
|
||
|
||
if(isset($_POST["org"]))
|
||
$pdf->Text($x, $y+$QR_size+5, $_POST["org"]." - ".$labels[$num_label]["uid"]);
|
||
else
|
||
$pdf->Text($x, $y+$QR_size+5, $labels[$num_label]["uid"]);
|
||
|
||
$micro = explode(" ",microtime());
|
||
$id = time().$micro[0];
|
||
|
||
$student_data = 'BEGIN:VCARD'.urldecode("%0A");
|
||
$student_data.= 'N:'.$labels[$num_label]["cn"].urldecode("%0A");
|
||
$student_data.= 'ROLE:Student'.urldecode("%0A");
|
||
|
||
if(isset($labels[$num_label]["nie"]))
|
||
$student_data.= 'UID:'.$labels[$num_label]["nie"].urldecode("%0A");
|
||
|
||
if(isset($_POST["org"]))
|
||
$student_data.= 'ORG:'.$_POST["org"].urldecode("%0A");
|
||
|
||
if(isset($_POST["address"]))
|
||
$student_data.= 'ADR:'.$_POST["address"].urldecode("%0A");
|
||
|
||
if(isset($_POST["phone"]))
|
||
$student_data.= 'TEL:'.$_POST["phone"].urldecode("%0A");
|
||
|
||
if(isset($_POST["email"]))
|
||
$student_data.= 'EMAIL:'.$_POST["email"].urldecode("%0A");
|
||
|
||
if(isset($_POST["web"]))
|
||
$student_data.= 'URL:'.$_POST["web"].urldecode("%0A");
|
||
|
||
$student_data.= 'END:VCARD';
|
||
|
||
generateQRCode($student_data,"tmp/QR".$id.".png");
|
||
|
||
if(file_exists("tmp/QR".$id.".png")){
|
||
$pdf->Image("tmp/QR".$id.".png",$x,$y,$QR_size);
|
||
@unlink("tmp/QR".$id.".png");
|
||
}
|
||
|
||
if($labels[$num_label]["foto"]!=""){
|
||
$photoStudent = "tmp/Alu".$id.".png";
|
||
|
||
$im = @imagepng(@imagecreatefromstring($labels[$num_label]["foto"]),$photoStudent);
|
||
|
||
if ($im !== false && file_exists($photoStudent))
|
||
$pdf->Image($photoStudent, $x + $QR_size, $y, $photoWidth, $photoHeight);
|
||
|
||
@unlink($photoStudent);
|
||
}
|
||
}
|
||
|
||
$num_label++;
|
||
|
||
if(($i+1)==$num_rows && ($j+1)==$num_cols && ($num_label+1)<count($labels)){
|
||
$pdf->AddPage();
|
||
$i=0;
|
||
$j=-1;
|
||
}
|
||
}
|
||
}
|
||
$pdf->Output();
|
||
exit();
|
||
} elseif($_POST["action"]=="generate_spreadsheet"){
|
||
require_once('ods/ods.php');
|
||
|
||
// Conectamos con LDAP
|
||
$user="cn=".$_POST["userLDAP"].",ou=People,dc=instituto,dc=extremadura,dc=es";
|
||
|
||
$conex=ldap_connect("ldaps://".$_POST["hostLDAP"], 636) or die ("No ha sido posible conectarse al servidor<br><br><input type='button' value='Volver' onClick='location.href=\"index.php\"'/>");
|
||
|
||
if (!@ldap_set_option($conex, LDAP_OPT_PROTOCOL_VERSION, 3))
|
||
die("Falló la configuracion de protocolo version 3<br><br><input type='button' value='Volver' onClick='location.href=\"index.php\"'/>");
|
||
|
||
if (!@ldap_bind($conex, $user, $_POST["password"]))
|
||
die("Upsss, falló la autenticación. Vuelve a intentarlo otra vez.<br><br><input type='button' value='Volver' onClick='location.href=\"index.php\"'/>");
|
||
|
||
// Obtenemos la info de LDAP
|
||
$dn = "ou=Group,dc=instituto,dc=extremadura,dc=es";
|
||
|
||
$filter="(|";
|
||
for($i=0;$i<count($_POST["classroomGroup"]);$i++){
|
||
$filter.="(cn=".$_POST["classroomGroup"][$i].")";
|
||
}
|
||
$filter.=")";
|
||
|
||
$fields = array("cn","grouptype","memberuid");
|
||
$sr=ldap_search($conex, $dn, $filter,$fields);
|
||
$groups = ldap_get_entries($conex, $sr);
|
||
|
||
for($i=0;$i<count($groups);$i++){
|
||
if($groups[$i]["grouptype"][0]=="school_class"){
|
||
for($j=0;$j<count($groups[$i]["memberuid"]);$j++){
|
||
if($groups[$i]["memberuid"][$j]!=""){
|
||
$listGroups[$groups[$i]["cn"][0]][] = $groups[$i]["memberuid"][$j];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
ksort($listGroups);
|
||
|
||
$filter = "";
|
||
if($_POST["filter"]!="")
|
||
$filter = $_POST["filter"]."*";
|
||
|
||
$dn = "ou=People,dc=instituto,dc=extremadura,dc=es";
|
||
$fields = array("uid","cn","employeenumber");
|
||
$sr=ldap_search($conex, $dn, "uid=*".$filter, $fields);
|
||
$students_tmp = ldap_get_entries($conex, $sr);
|
||
|
||
$completeListGroups = array();
|
||
foreach($listGroups as $key=>$value){
|
||
sort($value);
|
||
|
||
$students = array();
|
||
for($i=0;$i<count($students_tmp);$i++){
|
||
if(in_array($students_tmp[$i]["uid"][0],$value))
|
||
$students[$students_tmp[$i]["uid"][0]] = array("class"=>$key,"cn"=>$students_tmp[$i]["cn"][0],"uid"=>$students_tmp[$i]["uid"][0],"nie"=>$students_tmp[$i]["employeenumber"][0]);
|
||
}
|
||
ksort($students);
|
||
$completeListGroups[$key] = $students;
|
||
}
|
||
|
||
$ods = new ods();
|
||
$ods->setPath2OdsFiles('ods');
|
||
|
||
$table = new odsTable('table 1');
|
||
|
||
foreach($completeListGroups as $key=>$group)
|
||
foreach($group as $key2=>$list){
|
||
$row = new odsTableRow();
|
||
$row->addCell( new odsTableCellString($list["class"]) );
|
||
$row->addCell( new odsTableCellString($list["cn"]) );
|
||
$row->addCell( new odsTableCellString($list["uid"]) );
|
||
$table->addRow($row);
|
||
}
|
||
|
||
$ods->addTable($table);
|
||
|
||
$ods->downloadOdsFile("ListadoAlumnos.ods");
|
||
}
|
||
?>
|
||
<html>
|
||
<head>
|
||
<title>Generador de etiquetas - Centros Educativos de Extremadura</title>
|
||
<link rel="stylesheet" type="text/css" media="screen" href="style.css" />
|
||
<script type="text/JavaScript" language="javascript" src="jquery/jquery-1.4.2.min.js"></script>
|
||
<link rel="stylesheet" type="text/css" media="screen" href="jquery/ui/css/ui-lightness/jquery-ui-1.8.5.custom.css" />
|
||
<script type="text/JavaScript" language="javascript" src="jquery/ui/jquery-ui-1.8.5.custom.min.js"></script>
|
||
|
||
<script languaje="javascript">
|
||
|
||
function cargaSelectOffset () {
|
||
var select = document.getElementById("offset");
|
||
for (i=1;i<=23;i++)
|
||
select.options[select.length] = new Option(i, i);
|
||
}
|
||
|
||
|
||
$(function() {
|
||
$("#sliderHeight").slider({
|
||
value:70,
|
||
min: 30,
|
||
max: 150,
|
||
step: 1,
|
||
slide: function(event, ui) {
|
||
$("#height").val(ui.value);
|
||
}
|
||
});
|
||
$("#height").val($("#sliderHeight").slider("value"));
|
||
|
||
$("#sliderWidth").slider({
|
||
value:37,
|
||
min: 10,
|
||
max: 100,
|
||
step: 1,
|
||
slide: function(event, ui) {
|
||
$("#width").val(ui.value);
|
||
}
|
||
});
|
||
$("#width").val($("#sliderWidth").slider("value"));
|
||
|
||
|
||
$("#sliderRows").slider({
|
||
value:8,
|
||
min: 1,
|
||
max: 20,
|
||
step: 1,
|
||
slide: function(event, ui) {
|
||
$("#rows").val(ui.value);
|
||
}
|
||
});
|
||
$("#rows").val($("#sliderRows").slider("value"));
|
||
|
||
$("#sliderColumns").slider({
|
||
value:3,
|
||
min: 1,
|
||
max: 10,
|
||
step: 1,
|
||
slide: function(event, ui) {
|
||
$("#columns").val(ui.value);
|
||
}
|
||
});
|
||
$("#columns").val($("#sliderColumns").slider("value"));
|
||
|
||
$("#sliderxMargin").slider({
|
||
value:5,
|
||
min: 1,
|
||
max: 40,
|
||
step: 1,
|
||
slide: function(event, ui) {
|
||
$("#xMargin").val(ui.value);
|
||
}
|
||
});
|
||
$("#xMargin").val($("#sliderxMargin").slider("value"));
|
||
|
||
$("#slideryMargin").slider({
|
||
value:2,
|
||
min: 1,
|
||
max: 40,
|
||
step: 1,
|
||
slide: function(event, ui) {
|
||
$("#yMargin").val(ui.value);
|
||
}
|
||
});
|
||
$("#yMargin").val($("#slideryMargin").slider("value"));
|
||
|
||
$("#sliderphotoWidth").slider({
|
||
value:21,
|
||
min: 10,
|
||
max: 40,
|
||
step: 1,
|
||
slide: function(event, ui) {
|
||
$("#photoWidth").val(ui.value);
|
||
}
|
||
});
|
||
$("#photoWidth").val($("#sliderphotoWidth").slider("value"));
|
||
|
||
$("#sliderphotoHeight").slider({
|
||
value:25,
|
||
min: 10,
|
||
max: 40,
|
||
step: 1,
|
||
slide: function(event, ui) {
|
||
$("#photoHeight").val(ui.value);
|
||
}
|
||
});
|
||
$("#photoHeight").val($("#sliderphotoHeight").slider("value"));
|
||
|
||
$("#sliderqrSize").slider({
|
||
value:27,
|
||
min: 10,
|
||
max: 40,
|
||
step: 1,
|
||
slide: function(event, ui) {
|
||
$("#qrSize").val(ui.value);
|
||
}
|
||
});
|
||
$("#qrSize").val($("#sliderqrSize").slider("value"));
|
||
|
||
$( "buttonLabels, input:submit, a", "#buttonLabels" ).button();
|
||
$( "buttonGroups, input:button, a", "#buttonGroups" ).button();
|
||
|
||
$(".ui-state-error").hide();
|
||
$("#buttonLabels").hide();
|
||
})
|
||
|
||
function error(msn){
|
||
$("#messageGetGroups").html(msn);
|
||
$(".ui-state-error").show("slide",{},500);
|
||
}
|
||
|
||
function getGroups(){
|
||
$.getJSON("backend.php?hostLDAP="+$("#hostLDAP").val()+"&userLDAP="+$("#userLDAP").val()+"&password="+$("#password").val(),
|
||
function(data){
|
||
switch(data.msg){
|
||
case 'noConnect':{ error("No se pudo conectar con el Host"); break; }
|
||
case 'noProtocol':{ error("Falló la configuracion de protocolo"); break; }
|
||
case 'noPassword':{ error("Password incorrecto"); break; }
|
||
case 'noGroups':{ error("No se han encontrado grupos"); break; }
|
||
default:{
|
||
$(".ui-state-error").hide();
|
||
$("#buttonLabels").show();
|
||
$("#buttonGroups").empty();
|
||
$("#buttonGroups").append("Grupos<br><select multiple size='10' name='classroomGroup[]' id='classroomGroup'></select>");
|
||
$.each(data.groups, function(i,item){
|
||
$("#classroomGroup").append("<option value='"+item+"'>"+item+"</option>");
|
||
});
|
||
}
|
||
}
|
||
});
|
||
}
|
||
</script>
|
||
</head>
|
||
<body onload="cargaSelectOffset()">
|
||
<h1 style="text-align:center;">Generador de etiquetas - Centros Educativos de Extremadura</h1>
|
||
<form id='form_labels' method='POST' action="index.php">
|
||
<table style="width:100%;">
|
||
<tr>
|
||
<td colspan="2" style="width:25%; vertical-align:top;">
|
||
<fieldset><legend>LDAP</legend>
|
||
<div style="padding-left:10px">
|
||
<p>Servidor LDAP:<br>
|
||
<input type='text' id='hostLDAP' name='hostLDAP' class="text ui-widget-content ui-corner-all" value=''>
|
||
</p>
|
||
<p>Usuario:<br>
|
||
<input type='text' id='userLDAP' name='userLDAP' class="text ui-widget-content ui-corner-all" value='admin'>
|
||
</p>
|
||
<p>Contraseña:<br>
|
||
<input type='password' id='password' name='password' class="text ui-widget-content ui-corner-all">
|
||
</p>
|
||
<div id="buttonGroups"><input type="button" value="Obtener grupos" onClick="getGroups();"></div>
|
||
<br>
|
||
<div class="ui-state-error ui-corner-all" style="padding: 0pt 0.7em;">
|
||
<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: 0.3em;"></span>
|
||
<strong id="messageGetGroups"></strong></p>
|
||
</div>
|
||
</div>
|
||
</fieldset>
|
||
</td>
|
||
<td style="width:42%; vertical-align:top;">
|
||
<fieldset><legend>Parámetros etiquetas</legend>
|
||
<div style="padding-left:10px">
|
||
<p>
|
||
<label for="height">Ancho Etiqueta:</label>
|
||
<input type="text" id="height" name="height" style="border:0; color:#f6931f; font-weight:bold; width:30px; text-align:center;" />
|
||
<div id="sliderHeight" style="width:300px;"></div>
|
||
</p>
|
||
<p>
|
||
<label for="width">Alto Etiqueta:</label>
|
||
<input type="text" id="width" name="width" style="border:0; color:#f6931f; font-weight:bold; width:30px; text-align:center;" />
|
||
<div id="sliderWidth" style="width:300px;"></div>
|
||
</p>
|
||
<p>
|
||
<label for="rows">Filas:</label>
|
||
<input type="text" id="rows" name="rows" style="border:0; color:#f6931f; font-weight:bold; width:30px; text-align:center;" />
|
||
<div id="sliderRows" style="width:300px;"></div>
|
||
</p>
|
||
<p>
|
||
<label for="columns">Columnas:</label>
|
||
<input type="text" id="columns" name="columns" style="border:0; color:#f6931f; font-weight:bold; width:30px; text-align:center;" />
|
||
<div id="sliderColumns" style="width:300px;"></div>
|
||
</p>
|
||
<p>
|
||
<label for="xMargin">Margen X:</label>
|
||
<input type="text" id="xMargin" name="xMargin" style="border:0; color:#f6931f; font-weight:bold; width:30px; text-align:center;" />
|
||
<div id="sliderxMargin" style="width:300px;"></div>
|
||
</p>
|
||
<p>
|
||
<label for="yMargin">Margen Y:</label>
|
||
<input type="text" id="yMargin" name="yMargin" style="border:0; color:#f6931f; font-weight:bold; width:30px; text-align:center;" />
|
||
<div id="slideryMargin" style="width:300px;"></div>
|
||
</p>
|
||
<p>
|
||
<label for="photoSize">Tamaño Foto (Ancho):</label>
|
||
<input type="text" id="photoWidth" name="photoWidth" style="border:0; color:#f6931f; font-weight:bold; width:30px; text-align:center;" />
|
||
<div id="sliderphotoWidth" style="width:300px;"></div>
|
||
</p>
|
||
<p>
|
||
<label for="photoSize">Tamaño Foto (Alto):</label>
|
||
<input type="text" id="photoHeight" name="photoHeight" style="border:0; color:#f6931f; font-weight:bold; width:30px; text-align:center;" />
|
||
<div id="sliderphotoHeight" style="width:300px;"></div>
|
||
</p>
|
||
<p>
|
||
<label for="qrSize">Tamaño QR-Code:</label>
|
||
<input type="text" id="qrSize" name="qrSize" style="border:0; color:#f6931f; font-weight:bold; width:30px; text-align:center;" />
|
||
<div id="sliderqrSize" style="width:300px;"></div>
|
||
</p>
|
||
<p>
|
||
<label for="filter">Filtro:</label><br>
|
||
<input type="text" id="filter" name="filter" class="text ui-widget-content ui-corner-all"/> Valores separados por comas <b>(p.e. jprado, agordillo)</b>
|
||
</p>
|
||
<p>
|
||
<label for="offset">Empezar en la posición</label><br>
|
||
<select id="offset" name="offset">
|
||
</select>
|
||
</p>
|
||
<p style="text-align:center; font-weight:bold;">Parámetros por defecto para etiquetas apli24</p>
|
||
</div>
|
||
</fieldset>
|
||
</td>
|
||
<td style="width:33%; vertical-align:top;">
|
||
<fieldset><legend>Datos QR-Code (opcional) <a href="http://es.wikipedia.org/wiki/C%C3%B3digo_QR" target="_blank">Info Wikipedia</a></legend>
|
||
<div style="padding-left:10px">
|
||
<p>Organización:<br>
|
||
<input type="text" id="org" name="org" class="text ui-widget-content ui-corner-all"/> (p.e. IES Sta Eulalia)
|
||
</p>
|
||
<p>Dirección<br>
|
||
<input type="text" id="address" name="address" class="text ui-widget-content ui-corner-all"/>
|
||
</p>
|
||
<p>Teléfono<br>
|
||
<input type="text" id="phone" name="phone" class="text ui-widget-content ui-corner-all"/>
|
||
</p>
|
||
<p>Email<br>
|
||
<input type="text" id="email" name="email" class="text ui-widget-content ui-corner-all"/>
|
||
</p>
|
||
<p>Web<br>
|
||
http://<input type="text" id="web" name="web" class="text ui-widget-content ui-corner-all"/>
|
||
</p>
|
||
<p style="text-align:center; font-weight:bold;">Se incluirá además el Nombre, Apellidos y NIE del alumno.</p>
|
||
</div>
|
||
</fieldset>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td colspan="4" style="text-align:center;"><p>Tipo
|
||
<select id="action" name="action">
|
||
<option value="generate_labels">Etiquetas</option>
|
||
<option value="generate_spreadsheet">Hoja de Cálculo</option>
|
||
</select>
|
||
</p>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td colspan="4" style="text-align:center;"><br><div id="buttonLabels"><input type="submit" value="Generar"></div></td>
|
||
</tr>
|
||
</table>
|
||
</form>
|
||
</body>
|
||
</html>
|
||
etiquetas-portatiles/trunk/fpdf/license.txt | ||
---|---|---|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||
of this software to use, copy, modify, distribute, sublicense, and/or sell
|
||
copies of the software, and to permit persons to whom the software is furnished
|
||
to do so.
|
||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
|
etiquetas-portatiles/trunk/fpdf/fpdf.php | ||
---|---|---|
<?php
|
||
/*******************************************************************************
|
||
* FPDF *
|
||
* *
|
||
* Version: 1.6 *
|
||
* Date: 2008-08-03 *
|
||
* Author: Olivier PLATHEY *
|
||
*******************************************************************************/
|
||
|
||
define('FPDF_VERSION','1.6');
|
||
|
||
class FPDF
|
||
{
|
||
var $page; //current page number
|
||
var $n; //current object number
|
||
var $offsets; //array of object offsets
|
||
var $buffer; //buffer holding in-memory PDF
|
||
var $pages; //array containing pages
|
||
var $state; //current document state
|
||
var $compress; //compression flag
|
||
var $k; //scale factor (number of points in user unit)
|
||
var $DefOrientation; //default orientation
|
||
var $CurOrientation; //current orientation
|
||
var $PageFormats; //available page formats
|
||
var $DefPageFormat; //default page format
|
||
var $CurPageFormat; //current page format
|
||
var $PageSizes; //array storing non-default page sizes
|
||
var $wPt,$hPt; //dimensions of current page in points
|
||
var $w,$h; //dimensions of current page in user unit
|
||
var $lMargin; //left margin
|
||
var $tMargin; //top margin
|
||
var $rMargin; //right margin
|
||
var $bMargin; //page break margin
|
||
var $cMargin; //cell margin
|
||
var $x,$y; //current position in user unit
|
||
var $lasth; //height of last printed cell
|
||
var $LineWidth; //line width in user unit
|
||
var $CoreFonts; //array of standard font names
|
||
var $fonts; //array of used fonts
|
||
var $FontFiles; //array of font files
|
||
var $diffs; //array of encoding differences
|
||
var $FontFamily; //current font family
|
||
var $FontStyle; //current font style
|
||
var $underline; //underlining flag
|
||
var $CurrentFont; //current font info
|
||
var $FontSizePt; //current font size in points
|
||
var $FontSize; //current font size in user unit
|
||
var $DrawColor; //commands for drawing color
|
||
var $FillColor; //commands for filling color
|
||
var $TextColor; //commands for text color
|
||
var $ColorFlag; //indicates whether fill and text colors are different
|
||
var $ws; //word spacing
|
||
var $images; //array of used images
|
||
var $PageLinks; //array of links in pages
|
||
var $links; //array of internal links
|
||
var $AutoPageBreak; //automatic page breaking
|
||
var $PageBreakTrigger; //threshold used to trigger page breaks
|
||
var $InHeader; //flag set when processing header
|
||
var $InFooter; //flag set when processing footer
|
||
var $ZoomMode; //zoom display mode
|
||
var $LayoutMode; //layout display mode
|
||
var $title; //title
|
||
var $subject; //subject
|
||
var $author; //author
|
||
var $keywords; //keywords
|
||
var $creator; //creator
|
||
var $AliasNbPages; //alias for total number of pages
|
||
var $PDFVersion; //PDF version number
|
||
|
||
/*******************************************************************************
|
||
* *
|
||
* Public methods *
|
||
* *
|
||
*******************************************************************************/
|
||
function FPDF($orientation='P', $unit='mm', $format='A4')
|
||
{
|
||
//Some checks
|
||
$this->_dochecks();
|
||
//Initialization of properties
|
||
$this->page=0;
|
||
$this->n=2;
|
||
$this->buffer='';
|
||
$this->pages=array();
|
||
$this->PageSizes=array();
|
||
$this->state=0;
|
||
$this->fonts=array();
|
||
$this->FontFiles=array();
|
||
$this->diffs=array();
|
||
$this->images=array();
|
||
$this->links=array();
|
||
$this->InHeader=false;
|
||
$this->InFooter=false;
|
||
$this->lasth=0;
|
||
$this->FontFamily='';
|
||
$this->FontStyle='';
|
||
$this->FontSizePt=12;
|
||
$this->underline=false;
|
||
$this->DrawColor='0 G';
|
||
$this->FillColor='0 g';
|
||
$this->TextColor='0 g';
|
||
$this->ColorFlag=false;
|
||
$this->ws=0;
|
||
//Standard fonts
|
||
$this->CoreFonts=array('courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique',
|
||
'helvetica'=>'Helvetica', 'helveticaB'=>'Helvetica-Bold', 'helveticaI'=>'Helvetica-Oblique', 'helveticaBI'=>'Helvetica-BoldOblique',
|
||
'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic',
|
||
'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats');
|
||
//Scale factor
|
||
if($unit=='pt')
|
||
$this->k=1;
|
||
elseif($unit=='mm')
|
||
$this->k=72/25.4;
|
||
elseif($unit=='cm')
|
||
$this->k=72/2.54;
|
||
elseif($unit=='in')
|
||
$this->k=72;
|
||
else
|
||
$this->Error('Incorrect unit: '.$unit);
|
||
//Page format
|
||
$this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
|
||
'letter'=>array(612,792), 'legal'=>array(612,1008));
|
||
if(is_string($format))
|
||
$format=$this->_getpageformat($format);
|
||
$this->DefPageFormat=$format;
|
||
$this->CurPageFormat=$format;
|
||
//Page orientation
|
||
$orientation=strtolower($orientation);
|
||
if($orientation=='p' || $orientation=='portrait')
|
||
{
|
||
$this->DefOrientation='P';
|
||
$this->w=$this->DefPageFormat[0];
|
||
$this->h=$this->DefPageFormat[1];
|
||
}
|
||
elseif($orientation=='l' || $orientation=='landscape')
|
||
{
|
||
$this->DefOrientation='L';
|
||
$this->w=$this->DefPageFormat[1];
|
||
$this->h=$this->DefPageFormat[0];
|
||
}
|
||
else
|
||
$this->Error('Incorrect orientation: '.$orientation);
|
||
$this->CurOrientation=$this->DefOrientation;
|
||
$this->wPt=$this->w*$this->k;
|
||
$this->hPt=$this->h*$this->k;
|
||
//Page margins (1 cm)
|
||
$margin=28.35/$this->k;
|
||
$this->SetMargins($margin,$margin);
|
||
//Interior cell margin (1 mm)
|
||
$this->cMargin=$margin/10;
|
||
//Line width (0.2 mm)
|
||
$this->LineWidth=.567/$this->k;
|
||
//Automatic page break
|
||
$this->SetAutoPageBreak(true,2*$margin);
|
||
//Full width display mode
|
||
$this->SetDisplayMode('fullwidth');
|
||
//Enable compression
|
||
$this->SetCompression(true);
|
||
//Set default PDF version number
|
||
$this->PDFVersion='1.3';
|
||
}
|
||
|
||
function SetMargins($left, $top, $right=null)
|
||
{
|
||
//Set left, top and right margins
|
||
$this->lMargin=$left;
|
||
$this->tMargin=$top;
|
||
if($right===null)
|
||
$right=$left;
|
||
$this->rMargin=$right;
|
||
}
|
||
|
||
function SetLeftMargin($margin)
|
||
{
|
||
//Set left margin
|
||
$this->lMargin=$margin;
|
||
if($this->page>0 && $this->x<$margin)
|
||
$this->x=$margin;
|
||
}
|
||
|
||
function SetTopMargin($margin)
|
||
{
|
||
//Set top margin
|
||
$this->tMargin=$margin;
|
||
}
|
||
|
||
function SetRightMargin($margin)
|
||
{
|
||
//Set right margin
|
||
$this->rMargin=$margin;
|
||
}
|
||
|
||
function SetAutoPageBreak($auto, $margin=0)
|
||
{
|
||
//Set auto page break mode and triggering margin
|
||
$this->AutoPageBreak=$auto;
|
||
$this->bMargin=$margin;
|
||
$this->PageBreakTrigger=$this->h-$margin;
|
||
}
|
||
|
||
function SetDisplayMode($zoom, $layout='continuous')
|
||
{
|
||
//Set display mode in viewer
|
||
if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
|
||
$this->ZoomMode=$zoom;
|
||
else
|
||
$this->Error('Incorrect zoom display mode: '.$zoom);
|
||
if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
|
||
$this->LayoutMode=$layout;
|
||
else
|
||
$this->Error('Incorrect layout display mode: '.$layout);
|
||
}
|
||
|
||
function SetCompression($compress)
|
||
{
|
||
//Set page compression
|
||
if(function_exists('gzcompress'))
|
||
$this->compress=$compress;
|
||
else
|
||
$this->compress=false;
|
||
}
|
||
|
||
function SetTitle($title, $isUTF8=false)
|
||
{
|
||
//Title of document
|
||
if($isUTF8)
|
||
$title=$this->_UTF8toUTF16($title);
|
||
$this->title=$title;
|
||
}
|
||
|
||
function SetSubject($subject, $isUTF8=false)
|
||
{
|
||
//Subject of document
|
||
if($isUTF8)
|
||
$subject=$this->_UTF8toUTF16($subject);
|
||
$this->subject=$subject;
|
||
}
|
||
|
||
function SetAuthor($author, $isUTF8=false)
|
||
{
|
||
//Author of document
|
||
if($isUTF8)
|
||
$author=$this->_UTF8toUTF16($author);
|
||
$this->author=$author;
|
||
}
|
||
|
||
function SetKeywords($keywords, $isUTF8=false)
|
||
{
|
||
//Keywords of document
|
||
if($isUTF8)
|
||
$keywords=$this->_UTF8toUTF16($keywords);
|
||
$this->keywords=$keywords;
|
||
}
|
||
|
||
function SetCreator($creator, $isUTF8=false)
|
||
{
|
||
//Creator of document
|
||
if($isUTF8)
|
||
$creator=$this->_UTF8toUTF16($creator);
|
||
$this->creator=$creator;
|
||
}
|
||
|
||
function AliasNbPages($alias='{nb}')
|
||
{
|
||
//Define an alias for total number of pages
|
||
$this->AliasNbPages=$alias;
|
||
}
|
||
|
||
function Error($msg)
|
||
{
|
||
//Fatal error
|
||
die('<b>FPDF error:</b> '.$msg);
|
||
}
|
||
|
||
function Open()
|
||
{
|
||
//Begin document
|
||
$this->state=1;
|
||
}
|
||
|
||
function Close()
|
||
{
|
||
//Terminate document
|
||
if($this->state==3)
|
||
return;
|
||
if($this->page==0)
|
||
$this->AddPage();
|
||
//Page footer
|
||
$this->InFooter=true;
|
||
$this->Footer();
|
||
$this->InFooter=false;
|
||
//Close page
|
||
$this->_endpage();
|
||
//Close document
|
||
$this->_enddoc();
|
||
}
|
||
|
||
function AddPage($orientation='', $format='')
|
||
{
|
||
//Start a new page
|
||
if($this->state==0)
|
||
$this->Open();
|
||
$family=$this->FontFamily;
|
||
$style=$this->FontStyle.($this->underline ? 'U' : '');
|
||
$size=$this->FontSizePt;
|
||
$lw=$this->LineWidth;
|
||
$dc=$this->DrawColor;
|
||
$fc=$this->FillColor;
|
||
$tc=$this->TextColor;
|
||
$cf=$this->ColorFlag;
|
||
if($this->page>0)
|
||
{
|
||
//Page footer
|
||
$this->InFooter=true;
|
||
$this->Footer();
|
||
$this->InFooter=false;
|
||
//Close page
|
||
$this->_endpage();
|
||
}
|
||
//Start new page
|
||
$this->_beginpage($orientation,$format);
|
||
//Set line cap style to square
|
||
$this->_out('2 J');
|
||
//Set line width
|
||
$this->LineWidth=$lw;
|
||
$this->_out(sprintf('%.2F w',$lw*$this->k));
|
||
//Set font
|
||
if($family)
|
||
$this->SetFont($family,$style,$size);
|
||
//Set colors
|
||
$this->DrawColor=$dc;
|
||
if($dc!='0 G')
|
||
$this->_out($dc);
|
||
$this->FillColor=$fc;
|
||
if($fc!='0 g')
|
||
$this->_out($fc);
|
||
$this->TextColor=$tc;
|
||
$this->ColorFlag=$cf;
|
||
//Page header
|
||
$this->InHeader=true;
|
||
$this->Header();
|
||
$this->InHeader=false;
|
||
//Restore line width
|
||
if($this->LineWidth!=$lw)
|
||
{
|
||
$this->LineWidth=$lw;
|
||
$this->_out(sprintf('%.2F w',$lw*$this->k));
|
||
}
|
||
//Restore font
|
||
if($family)
|
||
$this->SetFont($family,$style,$size);
|
||
//Restore colors
|
||
if($this->DrawColor!=$dc)
|
||
{
|
||
$this->DrawColor=$dc;
|
||
$this->_out($dc);
|
||
}
|
||
if($this->FillColor!=$fc)
|
||
{
|
||
$this->FillColor=$fc;
|
||
$this->_out($fc);
|
||
}
|
||
$this->TextColor=$tc;
|
||
$this->ColorFlag=$cf;
|
||
}
|
||
|
||
function Header()
|
||
{
|
||
//To be implemented in your own inherited class
|
||
}
|
||
|
||
function Footer()
|
||
{
|
||
//To be implemented in your own inherited class
|
||
}
|
||
|
||
function PageNo()
|
||
{
|
||
//Get current page number
|
||
return $this->page;
|
||
}
|
||
|
||
function SetDrawColor($r, $g=null, $b=null)
|
||
{
|
||
//Set color for all stroking operations
|
||
if(($r==0 && $g==0 && $b==0) || $g===null)
|
||
$this->DrawColor=sprintf('%.3F G',$r/255);
|
||
else
|
||
$this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
|
||
if($this->page>0)
|
||
$this->_out($this->DrawColor);
|
||
}
|
||
|
||
function SetFillColor($r, $g=null, $b=null)
|
||
{
|
||
//Set color for all filling operations
|
||
if(($r==0 && $g==0 && $b==0) || $g===null)
|
||
$this->FillColor=sprintf('%.3F g',$r/255);
|
||
else
|
||
$this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
|
||
$this->ColorFlag=($this->FillColor!=$this->TextColor);
|
||
if($this->page>0)
|
||
$this->_out($this->FillColor);
|
||
}
|
||
|
||
function SetTextColor($r, $g=null, $b=null)
|
||
{
|
||
//Set color for text
|
||
if(($r==0 && $g==0 && $b==0) || $g===null)
|
||
$this->TextColor=sprintf('%.3F g',$r/255);
|
||
else
|
||
$this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
|
||
$this->ColorFlag=($this->FillColor!=$this->TextColor);
|
||
}
|
||
|
||
function GetStringWidth($s)
|
||
{
|
||
//Get width of a string in the current font
|
||
$s=(string)$s;
|
||
$cw=&$this->CurrentFont['cw'];
|
||
$w=0;
|
||
$l=strlen($s);
|
||
for($i=0;$i<$l;$i++)
|
||
$w+=$cw[$s[$i]];
|
||
return $w*$this->FontSize/1000;
|
||
}
|
||
|
||
function SetLineWidth($width)
|
||
{
|
||
//Set line width
|
||
$this->LineWidth=$width;
|
||
if($this->page>0)
|
||
$this->_out(sprintf('%.2F w',$width*$this->k));
|
||
}
|
||
|
||
function Line($x1, $y1, $x2, $y2)
|
||
{
|
||
//Draw a line
|
||
$this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k));
|
||
}
|
||
|
||
function Rect($x, $y, $w, $h, $style='')
|
||
{
|
||
//Draw a rectangle
|
||
if($style=='F')
|
||
$op='f';
|
||
elseif($style=='FD' || $style=='DF')
|
||
$op='B';
|
||
else
|
||
$op='S';
|
||
$this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
|
||
}
|
||
|
||
function AddFont($family, $style='', $file='')
|
||
{
|
||
//Add a TrueType or Type1 font
|
||
$family=strtolower($family);
|
||
if($file=='')
|
||
$file=str_replace(' ','',$family).strtolower($style).'.php';
|
||
if($family=='arial')
|
||
$family='helvetica';
|
||
$style=strtoupper($style);
|
||
if($style=='IB')
|
||
$style='BI';
|
||
$fontkey=$family.$style;
|
||
if(isset($this->fonts[$fontkey]))
|
||
return;
|
||
include($this->_getfontpath().$file);
|
||
if(!isset($name))
|
||
$this->Error('Could not include font definition file');
|
||
$i=count($this->fonts)+1;
|
||
$this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file);
|
||
if($diff)
|
||
{
|
||
//Search existing encodings
|
||
$d=0;
|
||
$nb=count($this->diffs);
|
||
for($i=1;$i<=$nb;$i++)
|
||
{
|
||
if($this->diffs[$i]==$diff)
|
||
{
|
||
$d=$i;
|
||
break;
|
||
}
|
||
}
|
||
if($d==0)
|
||
{
|
||
$d=$nb+1;
|
||
$this->diffs[$d]=$diff;
|
||
}
|
||
$this->fonts[$fontkey]['diff']=$d;
|
||
}
|
||
if($file)
|
||
{
|
||
if($type=='TrueType')
|
||
$this->FontFiles[$file]=array('length1'=>$originalsize);
|
||
else
|
||
$this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2);
|
||
}
|
||
}
|
||
|
||
function SetFont($family, $style='', $size=0)
|
||
{
|
||
//Select a font; size given in points
|
||
global $fpdf_charwidths;
|
||
|
||
$family=strtolower($family);
|
||
if($family=='')
|
||
$family=$this->FontFamily;
|
||
if($family=='arial')
|
||
$family='helvetica';
|
||
elseif($family=='symbol' || $family=='zapfdingbats')
|
||
$style='';
|
||
$style=strtoupper($style);
|
||
if(strpos($style,'U')!==false)
|
||
{
|
||
$this->underline=true;
|
||
$style=str_replace('U','',$style);
|
||
}
|
||
else
|
||
$this->underline=false;
|
||
if($style=='IB')
|
||
$style='BI';
|
||
if($size==0)
|
||
$size=$this->FontSizePt;
|
||
//Test if font is already selected
|
||
if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
|
||
return;
|
||
//Test if used for the first time
|
||
$fontkey=$family.$style;
|
||
if(!isset($this->fonts[$fontkey]))
|
||
{
|
||
//Check if one of the standard fonts
|
||
if(isset($this->CoreFonts[$fontkey]))
|
||
{
|
||
if(!isset($fpdf_charwidths[$fontkey]))
|
||
{
|
||
//Load metric file
|
||
$file=$family;
|
||
if($family=='times' || $family=='helvetica')
|
||
$file.=strtolower($style);
|
||
include($this->_getfontpath().$file.'.php');
|
||
if(!isset($fpdf_charwidths[$fontkey]))
|
||
$this->Error('Could not include font metric file');
|
||
}
|
||
$i=count($this->fonts)+1;
|
||
$name=$this->CoreFonts[$fontkey];
|
||
$cw=$fpdf_charwidths[$fontkey];
|
||
$this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw);
|
||
}
|
||
else
|
||
$this->Error('Undefined font: '.$family.' '.$style);
|
||
}
|
||
//Select it
|
||
$this->FontFamily=$family;
|
||
$this->FontStyle=$style;
|
||
$this->FontSizePt=$size;
|
||
$this->FontSize=$size/$this->k;
|
||
$this->CurrentFont=&$this->fonts[$fontkey];
|
||
if($this->page>0)
|
||
$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
|
||
}
|
||
|
||
function SetFontSize($size)
|
||
{
|
||
//Set font size in points
|
||
if($this->FontSizePt==$size)
|
||
return;
|
||
$this->FontSizePt=$size;
|
||
$this->FontSize=$size/$this->k;
|
||
if($this->page>0)
|
||
$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
|
||
}
|
||
|
||
function AddLink()
|
||
{
|
||
//Create a new internal link
|
||
$n=count($this->links)+1;
|
||
$this->links[$n]=array(0, 0);
|
||
return $n;
|
||
}
|
||
|
||
function SetLink($link, $y=0, $page=-1)
|
||
{
|
||
//Set destination of internal link
|
||
if($y==-1)
|
||
$y=$this->y;
|
||
if($page==-1)
|
||
$page=$this->page;
|
||
$this->links[$link]=array($page, $y);
|
||
}
|
||
|
||
function Link($x, $y, $w, $h, $link)
|
||
{
|
||
//Put a link on the page
|
||
$this->PageLinks[$this->page][]=array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link);
|
||
}
|
||
|
||
function Text($x, $y, $txt)
|
||
{
|
||
//Output a string
|
||
$s=sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
|
||
if($this->underline && $txt!='')
|
||
$s.=' '.$this->_dounderline($x,$y,$txt);
|
||
if($this->ColorFlag)
|
||
$s='q '.$this->TextColor.' '.$s.' Q';
|
||
$this->_out($s);
|
||
}
|
||
|
||
function AcceptPageBreak()
|
||
{
|
||
//Accept automatic page break or not
|
||
return $this->AutoPageBreak;
|
||
}
|
||
|
||
function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
|
||
{
|
||
//Output a cell
|
||
$k=$this->k;
|
||
if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
|
||
{
|
||
//Automatic page break
|
||
$x=$this->x;
|
||
$ws=$this->ws;
|
||
if($ws>0)
|
||
{
|
||
$this->ws=0;
|
||
$this->_out('0 Tw');
|
||
}
|
||
$this->AddPage($this->CurOrientation,$this->CurPageFormat);
|
||
$this->x=$x;
|
||
if($ws>0)
|
||
{
|
||
$this->ws=$ws;
|
||
$this->_out(sprintf('%.3F Tw',$ws*$k));
|
||
}
|
||
}
|
||
if($w==0)
|
||
$w=$this->w-$this->rMargin-$this->x;
|
||
$s='';
|
||
if($fill || $border==1)
|
||
{
|
||
if($fill)
|
||
$op=($border==1) ? 'B' : 'f';
|
||
else
|
||
$op='S';
|
||
$s=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
|
||
}
|
||
if(is_string($border))
|
||
{
|
||
$x=$this->x;
|
||
$y=$this->y;
|
||
if(strpos($border,'L')!==false)
|
||
$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
|
||
if(strpos($border,'T')!==false)
|
||
$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
|
||
if(strpos($border,'R')!==false)
|
||
$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
|
||
if(strpos($border,'B')!==false)
|
||
$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
|
||
}
|
||
if($txt!=='')
|
||
{
|
||
if($align=='R')
|
||
$dx=$w-$this->cMargin-$this->GetStringWidth($txt);
|
||
elseif($align=='C')
|
||
$dx=($w-$this->GetStringWidth($txt))/2;
|
||
else
|
||
$dx=$this->cMargin;
|
||
if($this->ColorFlag)
|
||
$s.='q '.$this->TextColor.' ';
|
||
$txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt)));
|
||
$s.=sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2);
|
||
if($this->underline)
|
||
$s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
|
||
if($this->ColorFlag)
|
||
$s.=' Q';
|
||
if($link)
|
||
$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link);
|
||
}
|
||
if($s)
|
||
$this->_out($s);
|
||
$this->lasth=$h;
|
||
if($ln>0)
|
||
{
|
||
//Go to next line
|
||
$this->y+=$h;
|
||
if($ln==1)
|
||
$this->x=$this->lMargin;
|
||
}
|
||
else
|
||
$this->x+=$w;
|
||
}
|
||
|
||
function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false)
|
||
{
|
||
//Output text with automatic or explicit line breaks
|
||
$cw=&$this->CurrentFont['cw'];
|
||
if($w==0)
|
||
$w=$this->w-$this->rMargin-$this->x;
|
||
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
|
||
$s=str_replace("\r",'',$txt);
|
||
$nb=strlen($s);
|
||
if($nb>0 && $s[$nb-1]=="\n")
|
||
$nb--;
|
||
$b=0;
|
||
if($border)
|
||
{
|
||
if($border==1)
|
||
{
|
||
$border='LTRB';
|
||
$b='LRT';
|
||
$b2='LR';
|
||
}
|
||
else
|
||
{
|
||
$b2='';
|
||
if(strpos($border,'L')!==false)
|
||
$b2.='L';
|
||
if(strpos($border,'R')!==false)
|
||
$b2.='R';
|
||
$b=(strpos($border,'T')!==false) ? $b2.'T' : $b2;
|
||
}
|
||
}
|
||
$sep=-1;
|
||
$i=0;
|
||
$j=0;
|
||
$l=0;
|
||
$ns=0;
|
||
$nl=1;
|
||
while($i<$nb)
|
||
{
|
||
//Get next character
|
||
$c=$s[$i];
|
||
if($c=="\n")
|
||
{
|
||
//Explicit line break
|
||
if($this->ws>0)
|
||
{
|
||
$this->ws=0;
|
||
$this->_out('0 Tw');
|
||
}
|
||
$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
|
||
$i++;
|
||
$sep=-1;
|
||
$j=$i;
|
||
$l=0;
|
||
$ns=0;
|
||
$nl++;
|
||
if($border && $nl==2)
|
||
$b=$b2;
|
||
continue;
|
||
}
|
||
if($c==' ')
|
||
{
|
||
$sep=$i;
|
||
$ls=$l;
|
||
$ns++;
|
||
}
|
||
$l+=$cw[$c];
|
||
if($l>$wmax)
|
||
{
|
||
//Automatic line break
|
||
if($sep==-1)
|
||
{
|
||
if($i==$j)
|
||
$i++;
|
||
if($this->ws>0)
|
||
{
|
||
$this->ws=0;
|
||
$this->_out('0 Tw');
|
||
}
|
||
$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
|
||
}
|
||
else
|
||
{
|
||
if($align=='J')
|
||
{
|
||
$this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0;
|
||
$this->_out(sprintf('%.3F Tw',$this->ws*$this->k));
|
||
}
|
||
$this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill);
|
||
$i=$sep+1;
|
||
}
|
||
$sep=-1;
|
||
$j=$i;
|
||
$l=0;
|
||
$ns=0;
|
||
$nl++;
|
||
if($border && $nl==2)
|
||
$b=$b2;
|
||
}
|
||
else
|
||
$i++;
|
||
}
|
||
//Last chunk
|
||
if($this->ws>0)
|
||
{
|
||
$this->ws=0;
|
||
$this->_out('0 Tw');
|
||
}
|
||
if($border && strpos($border,'B')!==false)
|
||
$b.='B';
|
||
$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
|
||
$this->x=$this->lMargin;
|
||
}
|
||
|
||
function Write($h, $txt, $link='')
|
||
{
|
||
//Output text in flowing mode
|
||
$cw=&$this->CurrentFont['cw'];
|
||
$w=$this->w-$this->rMargin-$this->x;
|
||
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
|
||
$s=str_replace("\r",'',$txt);
|
||
$nb=strlen($s);
|
||
$sep=-1;
|
||
$i=0;
|
||
$j=0;
|
||
$l=0;
|
||
$nl=1;
|
||
while($i<$nb)
|
||
{
|
||
//Get next character
|
||
$c=$s[$i];
|
||
if($c=="\n")
|
||
{
|
||
//Explicit line break
|
||
$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link);
|
||
$i++;
|
||
$sep=-1;
|
||
$j=$i;
|
||
$l=0;
|
||
if($nl==1)
|
||
{
|
||
$this->x=$this->lMargin;
|
||
$w=$this->w-$this->rMargin-$this->x;
|
||
$wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
|
||
}
|
||
$nl++;
|
||
continue;
|
||
}
|
||
if($c==' ')
|
||
$sep=$i;
|
||
$l+=$cw[$c];
|
||
if($l>$wmax)
|
||
{
|
||
//Automatic line break
|
||
if($sep==-1)
|
||
{
|
Exportar a: Unified diff