package vehiculosServlet;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Locale;
import java.util.ResourceBundle;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import m05bClasses.m05bComun;
import m05bClasses.m05bConexion;
import m05bClasses.m05bConstantes;
import m05bClasses.m05bConstantesInformes;
import m05bClasses.m05bFileLog;
import m05bClasses.m05bInformes;

import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
import org.xml.sax.InputSource;

public class m05bImpVehiculoHistoricoServlet extends
		javax.servlet.http.HttpServlet {
	java.sql.Connection conn = null;
	m05bFileLog miLog = new m05bFileLog();
	m05bInformes miInforme = new m05bInformes();

	public static final String FO_REQUEST_PARAM = "fo";

	// Logger log = null;

	public void doPost(javax.servlet.http.HttpServletRequest request,
			javax.servlet.http.HttpServletResponse response)
			throws javax.servlet.ServletException, java.io.IOException {
		try {
			doGet(request, response);
		} catch (Exception e) {
			miLog.addTraza(e);
		}
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException {
		performTask(request, response);
	}

	// if(log == null)
	// {
	// Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
	// log = hierarchy.getLoggerFor("fop");
	// log.setPriority(Priority.WARN);
	// }

	public void performTask(javax.servlet.http.HttpServletRequest request,
			javax.servlet.http.HttpServletResponse response)
			throws ServletException {
		java.sql.Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		m05bComun miComun = new m05bComun();

		try {
			HttpSession session = request.getSession(true);

			ResourceBundle res = (ResourceBundle) session
					.getAttribute("resTit");

			Locale idiomaLocal = (Locale) session.getAttribute("Local");
			String idiomaSes = ((idiomaLocal.getLanguage() == null) ? "es"
					: idiomaLocal.getLanguage());
			String campoTexto = "",campoTexto2="",campoTexto3="C";
			String formatoFecha="dd/MM/yyyy";
			if (!idiomaSes.equals("es")){
				campoTexto = "E";
				campoTexto2 = "E_";
				campoTexto3 = "E";
				formatoFecha="yyyy/MM/dd";
			}
			m05bConexion miConex = new m05bConexion();
			conn = miConex.getConnection();
			String persona = (String) session.getAttribute("persona");
			// Obtención de información de BD
			// Vehículo
			// Recogemos la matricula
			String sMatricula = request.getParameter("Matricula");
			if ((sMatricula == null) || (sMatricula.equals(""))) {
				sMatricula = "";
			}

			String sDesDpto = "";
			String sColor = "";
			String sMarca = "";
			String sModelo = "";
			String sSituacion = "";
			String sFMatricula = "";
			String sExpediente = "";
			String sSerie = "";
			String sFecGarantia = "";
			String sFecDesde = "";
			String sFecHasta = "";
			String sCodigo = "";
			String sCV = "";
			String sFecBaja = "";
			String sPrecio = "";
			String sImporteBaja = "";
			String sMotivoBaja = "";
			String sDestinoBaja = "";

			String sDpto = "";
			String sDesDptoAnt = "";
			String sRangoAnt = "";
			double dNumero = 0.0;
			String sPoliza = "";
			String sCia = "";
			String sModalidad = "";
			String sTarjeta = "";
			String sCuenta = "";
			String sEntidad = "";
			String sConcepto = "";
			String sImporte = "";
			String sMunicipio = "";
			String sOrden = "";
			String sKilometros = "";
			String sTaller = "";
			String sDescripcion = "";

			String sFInsp = "";
			String sFPInsp = "";
			String sFRepet = "";
			String sEstado = "";
			String sResultado = "";

			String sDni = "";
			String sNombre = "";

			String sTipo = "";
			String sInfractor = "";
			String sResponsabilidad = "";
			String sParteContraria = "";
			// DATOS GENERALES
			String sSentencia = " SELECT " + m05bConstantes.COL_34_MATRICULA
					+ ", Marca." + m05bConstantes.COL_99_CODDESC + ", Marca."
					+ m05bConstantes.COL_99_DESCRIPCION + ","
					+ m05bConstantes.COL_34_MODELO + ","
					+ m05bConstantes.COL_17_DESCRIP + ", Color."
					+ m05bConstantes.COL_99_CODDESC + ", Color."
					+campoTexto+ m05bConstantes.COL_99_DESCRIPCION + ", Situacion."
					+ m05bConstantes.COL_99_CODDESC + ", Situacion."
					+ campoTexto+m05bConstantes.COL_99_DESCRIPCION + ","
					+ m05bConstantes.COL_34_KMACTUALES + ",TO_CHAR("
					+ m05bConstantes.COL_34_FMATRIC + ",'"+formatoFecha+"'),"
					+ m05bConstantes.COL_34_EXPDTE + ","
					+ m05bConstantes.COL_34_NSERIE + ",TO_CHAR("
					+ m05bConstantes.COL_34_FGARANTIA + ",'"+formatoFecha+"'),"
					+ m05bConstantes.COL_34_CR + ", TO_CHAR("
					+ m05bConstantes.COL_34_FBAJA + ",'"+formatoFecha+"'), "
					+ m05bConstantes.COL_34_PRECIO + ", "
					+ m05bConstantes.COL_34_IMPBAJA + ", "
					+ m05bConstantes.COL_34_MOTIVBAJA + ", "
					+ m05bConstantes.COL_34_DESTINO + ", NVL("
					+campoTexto2+ "DESCRIP_06,DESCRIP_06) FROM "
					+ m05bConstantes.TAB_VEHICULOS + ","
					+ m05bConstantes.TAB_DEPARTAMENTOS + ","
					+ m05bConstantes.TAB_MODELOS + ","
					+ m05bConstantes.TAB_DESCRIPCIONES + " Marca ,"
					+ m05bConstantes.TAB_DESCRIPCIONES + " Color ,"
					+ m05bConstantes.TAB_DESCRIPCIONES + " Situacion"
					+ " WHERE CODDPTO_34=COD_DPTO_06 AND " + m05bConstantes.COL_34_MODELO + "="
					+ m05bConstantes.COL_17_CODMOD + " AND MARCA."
					+ m05bConstantes.COL_99_CODTABLA + " (+) ='"
					+ m05bConstantes.DESC_MARCAS + "' AND MARCA."
					+ m05bConstantes.COL_99_CODDESC + " (+) = "
					+ m05bConstantes.COL_34_MARCA + " AND COLOR."
					+ m05bConstantes.COL_99_CODTABLA + " (+) ='"
					+ m05bConstantes.DESC_COLORES + "' AND COLOR."
					+ m05bConstantes.COL_99_CODDESC + " (+) = "
					+ m05bConstantes.COL_34_COLOR + " AND SITUACION."
					+ m05bConstantes.COL_99_CODTABLA + " (+) ='"
					+ m05bConstantes.DESC_SITUACIONES + "' AND SITUACION."
					+ m05bConstantes.COL_99_CODDESC + " (+) = "
					+ m05bConstantes.COL_34_SITUACION + " and "
					+ m05bConstantes.COL_34_MATRICULA + "='" + sMatricula + "'";
			// DATOS DEPARTAMENTO
			String sSqlDepartamento = " SELECT "
					+ m05bConstantes.COL_44_CODDPTO + ",NVL("
					+campoTexto2+ "DESCRIP_06,DESCRIP_06)" + ",TO_CHAR("
					+ m05bConstantes.COL_44_FCAMBIO + ",'"+formatoFecha+"'),TO_CHAR("
					+ m05bConstantes.COL_44_FFIN + ",'"+formatoFecha+"'),DECODE("
					+ m05bConstantes.COL_44_FFIN + ",'','"+formatoFecha+"',TO_CHAR("
					+ m05bConstantes.COL_44_FFIN + ",'dd/mm/yyyy')) FROM "
					+ m05bConstantes.TAB_HIST_VEHICULOS + " inner join M0506T00 on CODDPTO_44=COD_DPTO_06 WHERE "
					+ m05bConstantes.COL_44_MATRICULA + "='" + sMatricula
					+ "' ORDER BY 5" + " DESC , 4 DESC";
			
		
			
			// DATOS SEGUROS
			String sSqlSeguros = " SELECT  " + m05bConstantes.COL_13_MATRICULA
					+ "," + m05bConstantes.COL_13_POLIZA + ","
					+ m05bConstantes.COL_13_POLIZAV + ","
					+ m05bConstantes.COL_13_CIA + ","
					+ m05bConstantes.COL_13_MODAL + ", NVL(T."
					+ campoTexto+m05bConstantes.COL_99_DESCRIPCION +",T."+m05bConstantes.COL_99_DESCRIPCION+ ") FROM "
					+ m05bConstantes.TAB_HIST_SEGUROS + ","
					+ m05bConstantes.TAB_DESCRIPCIONES + "  T " + " WHERE "
					+ m05bConstantes.COL_13_MATRICULA + "='" + sMatricula
					+ "' AND T." + m05bConstantes.COL_99_CODTABLA + " (+) ='"
					+ m05bConstantes.DESC_ESTADO_SEGUROS + "' AND "
					+ m05bConstantes.COL_13_ESTADO + "= T."
					+ m05bConstantes.COL_99_CODDESC + "(+) ORDER BY "
					+ m05bConstantes.COL_13_FALTA;
			miLog.addTraza(persona, "m05b - ImpVehiculoHistoricoSeguro:  ",
					"sSqlSeguros: " + sSqlSeguros,
					m05bConstantes.LOG_NIVEL_BAJO);
		
			// DATOS TARJETAS
			String sSqlTarjetas = " SELECT " + m05bConstantes.COL_14_MATRICULA
					+ "," + m05bConstantes.COL_14_TARJETA + ","
					+ m05bConstantes.COL_03_NOMBRE + ","
					+ m05bConstantes.COL_14_BANCO + ",NVL( S."
					+ campoTexto+m05bConstantes.COL_99_DESCRIPCION +",S."+m05bConstantes.COL_99_DESCRIPCION + ") FROM "
					+ m05bConstantes.TAB_BANCOS + ","
					+ m05bConstantes.TAB_HIST_TARJETAS + ","
					+ m05bConstantes.TAB_DESCRIPCIONES + "  S " + " WHERE "
					+ m05bConstantes.COL_14_BANCO + "  = "
					+ m05bConstantes.COL_03_NCUENTA + " (+) AND S."
					+ m05bConstantes.COL_99_CODTABLA + " (+) ="
					+ m05bConstantes.DESC_SIT_TARJETAS + " AND "
					+ m05bConstantes.COL_14_SITUACION + "= S."
					+ m05bConstantes.COL_99_CODDESC + " (+) AND "
					+ m05bConstantes.COL_14_MATRICULA + "='" + sMatricula
					+ "' ORDER BY " + m05bConstantes.COL_14_FALTA;
			// DATOS TASAS
			String sSqlTasas = " SELECT " + m05bConstantes.COL_32_MATRICULA
					+ ",NVL(T." +campoTexto+ m05bConstantes.COL_99_DESCRIPCION + ",T."
					+ m05bConstantes.COL_99_DESCRIPCION + "),"
					+ m05bConstantes.COL_32_IMPORTE + ",TO_CHAR("
					+ m05bConstantes.COL_32_FECHA + ",'"+formatoFecha+"'),"
					+ m05bConstantes.COL_24_DESC + " FROM "
					+ m05bConstantes.TAB_TASAS + ","
					+ m05bConstantes.TAB_DESCRIPCIONES + "  T,"
					+ m05bConstantes.TAB_POBLACIONES + " WHERE "
					+ m05bConstantes.COL_24_CODIGO + " (+) ="
					+ m05bConstantes.COL_32_MUNICIPIO + " AND T."
					+ m05bConstantes.COL_99_CODTABLA + " (+) ="
					+ m05bConstantes.DESC_CONCEPTOSTASAS + " AND "
					+ m05bConstantes.COL_32_CONCEPTO + "= T."
					+ m05bConstantes.COL_99_CODDESC + " (+) AND "
					+ m05bConstantes.COL_32_MATRICULA + "='" + sMatricula
					+ "' ORDER BY " + m05bConstantes.COL_32_FECHA;
			miLog.addTraza(persona, "m05b - ImpVehiculoHistoricoSeguro:  ",
					"sSqlTasas: " + sSqlTasas, m05bConstantes.LOG_NIVEL_BAJO);
			// DATOS ORDENES
			String sSqlOrdenes = " SELECT * FROM ( " + " SELECT "
					+ m05bConstantes.COL_20_MATRICULA + ","
					+ " DECODE(TO_CHAR(" + m05bConstantes.COL_20_CODIGO
					+ "),'','Revisión',TO_CHAR(" + m05bConstantes.COL_20_CODIGO
					+ ")),TO_CHAR(" + m05bConstantes.COL_20_FENTRADA
					+ ",'"+formatoFecha+"')," + m05bConstantes.COL_20_KM_ENTRADA
					+ "," + m05bConstantes.COL_30_DESCRIP + ","
					+ m05bConstantes.COL_20_DESCRIP + ",TO_CHAR("
					+ m05bConstantes.COL_20_FENTRADA + ",'"+formatoFecha+"')"
					+ " FROM " + m05bConstantes.TAB_REVISIONES + ","
					+ m05bConstantes.TAB_ORDENESTRAB + ","
					+ m05bConstantes.TAB_TALLER + " WHERE  "
					+ m05bConstantes.COL_35_ORDEN + "(+) = "
					+ m05bConstantes.COL_20_CODIGO + " AND "
					+ m05bConstantes.COL_20_MATRICULA + "='" + sMatricula
					+ "' AND " + m05bConstantes.COL_20_CODTALLER + "="
					+ m05bConstantes.COL_30_CODIGO + " UNION SELECT "
					+ m05bConstantes.COL_35_MATRICULA + "," + " DECODE( "
					+ m05bConstantes.COL_35_ORDEN + ",'','Revisión',"
					+ m05bConstantes.COL_35_ORDEN + "),TO_CHAR("
					+ m05bConstantes.COL_35_FECHA + ",'"+formatoFecha+"'),"
					+ m05bConstantes.COL_35_KMRE + "," + "'' ,"
					+ m05bConstantes.COL_35_DESC + ",TO_CHAR("
					+ m05bConstantes.COL_35_FECHA + ",'"+formatoFecha+"')" + " FROM "
					+ m05bConstantes.TAB_REVISIONES + " WHERE " + " ((("
					+ m05bConstantes.COL_35_ORDEN + ") Is Null)) AND "
					+ m05bConstantes.COL_35_MATRICULA + "='" + sMatricula
					+ "') order by 7 desc";
			miLog.addTraza(persona, "m05b - ImpVehiculoHistoricoSeguro:  ",
					"sSqlOrdenes: " + sSqlOrdenes,
					m05bConstantes.LOG_NIVEL_BAJO);
			// DATOS REVISIONES
			String sSqlRevisiones = " SELECT "
					+ m05bConstantes.COL_27_MATRICULA + ",TO_CHAR("
					+ m05bConstantes.COL_27_FINSPEC + ",'"+formatoFecha+"'),"
					+ m05bConstantes.COL_27_ESTADO + ","
					+ m05bConstantes.COL_27_RESULTADO + ",TO_CHAR("
					+ m05bConstantes.COL_27_FREPINSP
					+ ",'dd/mm/yyyy'),TO_CHAR("
					+ m05bConstantes.COL_27_FPRXINSPEC + ",'"+formatoFecha+"')"
					+ " FROM " + m05bConstantes.TAB_ITV + " WHERE "
					+ m05bConstantes.COL_27_MATRICULA + "='" + sMatricula
					+ "' " + " ORDER BY " + m05bConstantes.COL_27_FINSPEC
					+ " DESC ";
			// DATOS ASIGNACIONES
			String sSqlAsignaciones = " SELECT "
					+ m05bConstantes.COL_01_MATRICULA + ","
					+ m05bConstantes.COL_01_DNI + ","
					+ m05bConstantes.COL_21_NOMBRE + ",NVL("
					+ campoTexto+m05bConstantes.COL_04_DESCCARG +","+m05bConstantes.COL_04_DESCCARG + ") FROM "
					+ m05bConstantes.TAB_ASIGNACION + ","
					+ m05bConstantes.TAB_PERSONAL + ","
					+ m05bConstantes.TAB_CARGOS + " WHERE "
					+ m05bConstantes.COL_01_DNI + "="
					+ m05bConstantes.COL_21_DNI + " (+) AND "
					+ m05bConstantes.COL_21_CODCARGO + " = "
					+ m05bConstantes.COL_04_CODCARGO + " (+) AND "
					+ m05bConstantes.COL_01_MATRICULA + " = '" + sMatricula
					+ "' " + " GROUP BY " + m05bConstantes.COL_01_MATRICULA
					+ "," + m05bConstantes.COL_01_DNI + ","
					+ m05bConstantes.COL_21_NOMBRE + ",NVL("
					+ campoTexto+m05bConstantes.COL_04_DESCCARG +","+m05bConstantes.COL_04_DESCCARG + ")";
			miLog.addTraza(persona, "m05b - ImpVehiculoHistoricoSeguro:  ",
					"sSqlAsignaciones: " + sSqlAsignaciones,
					m05bConstantes.LOG_NIVEL_BAJO);
			// DATOS SINIESTROS
			String sSqlSiniestros = " SELECT "
					+ m05bConstantes.COL_29_MATRICULA + ",TO_CHAR("
					+ m05bConstantes.COL_29_FSINIESTRO + ",'"+formatoFecha+"'),"
					+ m05bConstantes.COL_21_NOMBRE + ","
					+ m05bConstantes.COL_29_MATRICULAC + ",NVL("
					+ campoTexto+m05bConstantes.COL_99_DESCRIPCION +","+m05bConstantes.COL_99_DESCRIPCION + ") FROM "
					+ m05bConstantes.TAB_PERSONAL + ","
					+ m05bConstantes.TAB_SINIESTROS + ","
					+ m05bConstantes.TAB_DESCRIPCIONES + " WHERE "
					+ m05bConstantes.COL_29_DNI + " = "
					+ m05bConstantes.COL_21_DNI + " (+)" + " AND "
					+ m05bConstantes.COL_29_MATRICULA + " = '" + sMatricula
					+ "' AND " + m05bConstantes.COL_99_CODTABLA + " (+) ='"
					+ m05bConstantes.DESC_RESPONSABILIDAD + "' AND "
					+ m05bConstantes.COL_99_CODDESC + " (+) ="
					+ m05bConstantes.COL_29_RESPONS + " ORDER BY "
					+ m05bConstantes.COL_29_FSINIESTRO + " desc";
			miLog.addTraza(persona, "m05b - ImpVehiculoHistoricoSeguro:  ",
					"sSqlSiniestros: " + sSqlSiniestros,
					m05bConstantes.LOG_NIVEL_BAJO);
			// DATOS SANCIONES
			String sSqlSanciones = " SELECT " + m05bConstantes.COL_45_MATRICULA
					+ "," + m05bConstantes.COL_45_CODIGO + ","
					+ m05bConstantes.COL_45_TIPO + "," + "DECODE ("
					+ m05bConstantes.COL_45_FDENUNCIA + ",'',TO_CHAR("
					+ m05bConstantes.COL_45_FSANCION
					+ ",'dd/mm/yyyy'),TO_CHAR("
					+ m05bConstantes.COL_45_FDENUNCIA + ",'"+formatoFecha+"')),"
					+ m05bConstantes.COL_21_NOMBRE + " FROM "
					+ m05bConstantes.TAB_PERSONAL + ","
					+ m05bConstantes.TAB_SANCIONES + " WHERE "
					+ m05bConstantes.COL_45_DNI + "= "
					+ m05bConstantes.COL_21_DNI + " (+) AND "
					+ m05bConstantes.COL_45_MATRICULA + " = '" + sMatricula
					+ "' ORDER BY " + m05bConstantes.COL_45_FDENUNCIA + " desc";
			miLog.addTraza(persona, "m05b - ImpVehiculoHistoricoSeguro:  ",
					"sSqlSanciones: " + sSqlSanciones,
					m05bConstantes.LOG_NIVEL_BAJO);
			// DATOS GASTOS
			String sSqlGastos = " SELECT  Matricula, Tarjeta, Tipo, SUM(Importe) FROM ( "
					+ " SELECT  "
					+ m05bConstantes.COL_46_MATRICULA
					+ " as Matricula, "
					+ m05bConstantes.COL_46_TARJETA
					+ " as Tarjeta,  NVL( "
					+ campoTexto+m05bConstantes.COL_99_DESCRIPCION
					+ ","+m05bConstantes.COL_99_DESCRIPCION
					+ ") as Tipo,      "
					+ " SUM("
					+ m05bConstantes.COL_46_IMPORTE
					+ ") as Importe"
					+ " FROM "
					+ m05bConstantes.TAB_HIST_OPEBANCOS
					+ ","
					+ m05bConstantes.TAB_DESCRIPCIONES
					+ " WHERE "
					+ m05bConstantes.COL_46_MATRICULA
					+ "='"
					+ sMatricula
					+ "' AND "
					+ m05bConstantes.COL_99_CODTABLA
					+ "='"
					+ m05bConstantes.DESC_CONCEPTOSGASTOS
					+ "' AND "
					+ m05bConstantes.COL_99_CODDESC
					+ "="
					+ m05bConstantes.COL_46_TIPO
					+ " group by "
					+ m05bConstantes.COL_46_MATRICULA
					+ ","
					+ m05bConstantes.COL_46_TARJETA
					+ ",NVL("
					+campoTexto+ m05bConstantes.COL_99_DESCRIPCION
					+","
					+ m05bConstantes.COL_99_DESCRIPCION
					+ ") UNION SELECT "
					+ m05bConstantes.COL_18_MATRICULA
					+ " as Matricula,"
					+ m05bConstantes.COL_18_TARJETA
					+ " as Tarjeta , NVL("
					+campoTexto+ m05bConstantes.COL_99_DESCRIPCION
					+","+ m05bConstantes.COL_99_DESCRIPCION					
					+ ") as Tipo,     "
					+ " SUM("
					+ m05bConstantes.COL_18_IMPORTE
					+ ") as Importe "
					+ " FROM "
					+ m05bConstantes.TAB_OPEBANCOS
					+ ","
					+ m05bConstantes.TAB_DESCRIPCIONES
					+ " WHERE "
					+ m05bConstantes.COL_18_MATRICULA
					+ "='"
					+ sMatricula
					+ "' AND "
					+ m05bConstantes.COL_99_CODTABLA
					+ "='"
					+ m05bConstantes.DESC_CONCEPTOSGASTOS
					+ "' AND "
					+ m05bConstantes.COL_99_CODDESC
					+ "="
					+ m05bConstantes.COL_18_TIPO
					+ " GROUP BY "
					+ m05bConstantes.COL_18_MATRICULA
					+ ","
					+ m05bConstantes.COL_18_TARJETA
					+ ",NVL("
							+campoTexto+ m05bConstantes.COL_99_DESCRIPCION
							+","+ m05bConstantes.COL_99_DESCRIPCION					
							+ ")"
					+ ") GROUP BY Matricula,Tarjeta,Tipo" + " ORDER BY 1,2,3 ";
			miLog.addTraza(persona, "m05b - ImpVehiculoHistoricoSeguro:  ",
					"sSqlGastos: " + sSqlGastos, m05bConstantes.LOG_NIVEL_BAJO);
			miLog.addTraza(persona, "m05b - ImpVehiculoHistoricoSeguro:  ",
					"sSentencia: " + sSentencia, m05bConstantes.LOG_NIVEL_BAJO);

			pstmt = conn.prepareStatement(sSentencia);
			rs = pstmt.executeQuery();

			// String foParam = request.getParameter(FO_REQUEST_PARAM);
			String sFoFileDir = "/datos/m05b/tmp/";
			File foFileDir = new File(sFoFileDir);
			File tmpFoFile = File.createTempFile("m05b", "Fo", foFileDir);

			FileOutputStream tmpFoFileStream = new FileOutputStream(tmpFoFile);

			String sLinea;
			sLinea = "<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n";
			tmpFoFileStream.write(sLinea.getBytes());

			sLinea = "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">\n";
			tmpFoFileStream.write(sLinea.getBytes());
			// LAYOUT DEL LISTADO
			sLinea = "<fo:layout-master-set>\n";
			tmpFoFileStream.write(sLinea.getBytes());
			sLinea = "	<fo:simple-page-master master-name=\"general\"  page-height=\"29.5cm\" page-width=\"21cm\" margin-top=\"2cm\" margin-bottom=\"2cm\" margin-left=\"2.5cm\" margin-right=\"2.5cm\">\n";
			tmpFoFileStream.write(sLinea.getBytes());
			sLinea = "		<fo:region-before extent=\"2cm\"/>\n";
			tmpFoFileStream.write(sLinea.getBytes());
			sLinea = "		<fo:region-body  margin-top=\"2.8cm\" margin-bottom=\"1.5cm\" />\n";
			tmpFoFileStream.write(sLinea.getBytes());
			sLinea = "		<fo:region-after  extent=\"1cm\"/>\n";
			tmpFoFileStream.write(sLinea.getBytes());
			sLinea = "		<fo:region-start extent=\"0cm\"/>\n";
			tmpFoFileStream.write(sLinea.getBytes());
			sLinea = "		<fo:region-end extent=\"0cm\"/>\n";
			tmpFoFileStream.write(sLinea.getBytes());

			sLinea = "	</fo:simple-page-master>\n";
			tmpFoFileStream.write(sLinea.getBytes());

			sLinea = "</fo:layout-master-set>\n";
			tmpFoFileStream.write(sLinea.getBytes());
			// PAGE-SEQUENCE DEL LISTADO
			sLinea = "<fo:page-sequence master-reference=\"general\">\n";
			tmpFoFileStream.write(sLinea.getBytes());

			// REGION BEFORE
			sLinea = "		<fo:static-content flow-name=\"xsl-region-before\" >\n";
			tmpFoFileStream.write(sLinea.getBytes());
			// -------------- CABECERA DEL LISTADO --------------
			// Cabecera 1
			sLinea = "      <fo:block text-align=\"end\">\n";
			tmpFoFileStream.write(sLinea.getBytes());
			sLinea = "      </fo:block>\n";
			tmpFoFileStream.write(sLinea.getBytes());
			sLinea = "      <fo:block font-weight=\"bold\" padding-top=\"10pt\">\n <![CDATA["
					+ res.getString("infHistoricoVeh.titulo")+" "
					+ sMatricula
					+ "]]></fo:block>\n";
			tmpFoFileStream.write(sLinea.getBytes());
			sLinea = " 		</fo:static-content>\n";
			tmpFoFileStream.write(sLinea.getBytes());

			// PIE DE PAGINA
			miInforme.fncGenerarPiePagina(tmpFoFileStream,
					m05bConstantesInformes.DIR_VERTICAL,campoTexto3,res.getString("pagina"));

			// BODY
			sLinea = "	<fo:flow flow-name=\"xsl-region-body\">\n";
			tmpFoFileStream.write(sLinea.getBytes());
			Context ctx = new InitialContext(System.getProperties());
			// -------------- DETALLE DEL LISTADO --------------
			int cont = 0;
			String dNumeroS = "";
			if (rs.next()) {
				sMatricula = rs.getString(1) == null ? "" : rs.getString(1);
				sMarca = rs.getString(3) == null ? "" : rs.getString(3);
				sModelo = rs.getString(5) == null ? "" : rs.getString(5);
				sColor = rs.getString(7) == null ? "" : rs.getString(7);
				sSituacion = rs.getString(9) == null ? "" : rs.getString(9);
				dNumeroS = (rs.getString(10) == null) ? "0" : rs.getString(10);
				sKilometros = miComun.formatearDblMiles(new Double(dNumeroS)
						.doubleValue());
				sKilometros = sKilometros.replaceAll(",", ".");
				sFMatricula = rs.getString(11) == null ? "" : rs.getString(11);
				//
				sExpediente = rs.getString(12) == null ? "" : rs.getString(12);
				sSerie = rs.getString(13) == null ? "" : rs.getString(13);
				sFecGarantia = rs.getString(14) == null ? "" : rs.getString(14);
				sCV = rs.getString(15) == null ? "" : rs.getString(15);
				sFecBaja = rs.getString(16) == null ? "" : rs.getString(16);
				dNumero = rs.getDouble(17);
				sPrecio = miComun.formatearDblMilesDec(dNumero);
				dNumero = rs.getDouble(18);
				sImporteBaja = miComun.formatearDblMilesDec(dNumero);
				sMotivoBaja = rs.getString(19) == null ? "" : rs.getString(19);
				sDestinoBaja = rs.getString(20) == null ? "" : rs.getString(20);
				sDesDpto = rs.getString(21) == null ? "" : rs.getString(21);

				// Linea0
				sLinea = "        <fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" background-color=\"rgb(200,200,200)\" font-size=\"12pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Departamento
				sLinea = "	    <fo:table-cell border-style=\"solid\" border-left-width=\"3pt\" border-right-width=\"3pt\" border-top-width=\"3pt\" border-bottom-width=\"3pt\" background-color=\"rgb(200,200,200)\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"left\"  padding-top=\"0.2mm\">\n "
						+ res.getString("infHistoricoVeh.titulotabla1")
						+ "</fo:block>";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				// Linea 1
				sLinea = "        <fo:table >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"30mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"30mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-header font-family=\"Helvetica\" font-size=\"8pt\" >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Primera Linea
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Matricula
				sLinea = "	    <fo:table-cell border-left-width=\"3pt\" border-top-width=\"3pt\" border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col1")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Marca
				sLinea = "	    <fo:table-cell  border-top-width=\"3pt\"  border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col2")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Modelo
				sLinea = "	    <fo:table-cell  border-top-width=\"3pt\"  border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col3")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Color
				sLinea = "	    <fo:table-cell  border-top-width=\"3pt\"  border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col4")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Situacion
				sLinea = "	    <fo:table-cell  border-top-width=\"3pt\"  border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col5")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// KM Actuales
				sLinea = "	    <fo:table-cell  border-top-width=\"3pt\" border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col6")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Fecha Matricula
				sLinea = "	    <fo:table-cell border-right-width=\"3pt\" border-top-width=\"3pt\" border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col7")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-header>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Linea 1
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Matricula
				sLinea = "	    <fo:table-cell border-left-width=\"3pt\" border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
						+ sMatricula + "]]></fo:block>";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Marca
				sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA[ "
						+ sMarca + "]]></fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Modelo
				sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
						+ sModelo + "]]></fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Color
				sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
						+ sColor + "]]></fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Situacion
				sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
						+ sSituacion + "]]></fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// KM Actuales
				sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
						+ sKilometros + "]]></fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Fecha Matricula
				sLinea = "	    <fo:table-cell border-right-width=\"3pt\" border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
						+ sFMatricula + "]]></fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				// Linea2
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "        <fo:table >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"35mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"35mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"30mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-header font-family=\"Helvetica\" font-size=\"8pt\" >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Primera Linea
				sLinea = "	    <fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// NExpediente
				sLinea = "	    <fo:table-cell border-left-width=\"3pt\" border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\" text-align=\"center\"  padding-top=\"0.2mm\"  >\n "
						+ res.getString("infHistoricoVeh.col8")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// NSerie
				sLinea = "	    <fo:table-cell border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  padding-top=\"0.2mm\" >\n "
						+ res.getString("infHistoricoVeh.col9")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Fecha Garantia
				sLinea = "	    <fo:table-cell border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\" text-align=\"center\"  padding-top=\"0.2mm\" >\n "
						+ res.getString("infHistoricoVeh.col10")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// CVReales
				sLinea = "	    <fo:table-cell border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\" text-align=\"center\"  padding-top=\"0.2mm\" >\n "
						+ res.getString("infHistoricoVeh.col11")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Fecha Baja
				sLinea = "	    <fo:table-cell border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"   padding-top=\"0.2mm\">\n "
						+ res.getString("infHistoricoVeh.col12")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Precio
				sLinea = "	    <fo:table-cell border-style=\"solid\" border-right-width=\"3pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col13")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-header>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Linea 1
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Expediente
				sLinea = "	    <fo:table-cell border-style=\"solid\" border-left-width=\"3pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\"  padding-top=\"0.2mm\">\n <![CDATA["
						+ sExpediente + "]]></fo:block>";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Serie
				sLinea = "	    <fo:table-cell border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\"  padding-top=\"0.2mm\">\n <![CDATA["
						+ sSerie + "]]></fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// CV
				sLinea = "	    <fo:table-cell border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\"  padding-top=\"0.2mm\">\n<![CDATA["
						+ sFecGarantia + "]]></fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Color
				sLinea = "	    <fo:table-cell border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\"  padding-top=\"0.2mm\">\n<![CDATA["
						+ sCV + "]]></fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// FBaja
				sLinea = "	    <fo:table-cell border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\"  padding-top=\"0.2mm\">\n<![CDATA["
						+ sFecBaja + "]]></fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Precio
				sLinea = "	    <fo:table-cell border-style=\"solid\" border-right-width=\"3pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\"  padding-top=\"0.2mm\">\n<![CDATA["
						+ sPrecio + "]]></fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Linea3
				sLinea = "        <fo:table >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"54mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"53mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"53mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-header font-family=\"Helvetica\" font-size=\"8pt\" >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Primera Linea
				sLinea = "	    <fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Importe Baja
				sLinea = "	    <fo:table-cell border-left-width=\"3pt\" border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\" text-align=\"center\"  padding-top=\"0.2mm\"  >\n "
						+ res.getString("infHistoricoVeh.col14")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Motivo Baja
				sLinea = "	    <fo:table-cell border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  padding-top=\"0.2mm\" >\n "
						+ res.getString("infHistoricoVeh.col15")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Destino Baja
				sLinea = "	    <fo:table-cell border-style=\"solid\" border-right-width=\"3pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\" text-align=\"center\"  padding-top=\"0.2mm\" >\n "
						+ res.getString("infHistoricoVeh.col16")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-header>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Importe Baja
				sLinea = "	    <fo:table-cell border-style=\"solid\" border-left-width=\"3pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\"  padding-top=\"0.2mm\">\n <![CDATA["
						+ sImporteBaja + "]]></fo:block>";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Motivo Baja
				sLinea = "	    <fo:table-cell border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\"  padding-top=\"0.2mm\">\n<![CDATA[ "
						+ sMotivoBaja + "]]></fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Destino Baja
				sLinea = "	    <fo:table-cell border-style=\"solid\" border-right-width=\"3pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\"  padding-top=\"0.2mm\">\n<![CDATA["
						+ sDestinoBaja + "]]></fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Linea4
				sLinea = "        <fo:table  space-after=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"160mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-header font-family=\"Helvetica\" font-size=\"8pt\" >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Primera Linea
				sLinea = "	    <fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Departamento
				sLinea = "	    <fo:table-cell border-left-width=\"3pt\"  border-right-width=\"3pt\"  border-style=\"solid\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\" text-align=\"center\"  padding-top=\"0.2mm\"  >\n "
						+ res.getString("infHistoricoVeh.col18")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-header>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Departamento
				sLinea = "	    <fo:table-cell border-style=\"solid\" border-bottom-width=\"3pt\" border-right-width=\"3pt\" border-left-width=\"3pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"center\"  padding-top=\"0.2mm\">\n <![CDATA["
						+ sDesDpto + "]]></fo:block>";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				// SACAMOS DEPARTAMENTOS
				if (pstmt != null) {
					rs.close();
					pstmt.close();
				}

				pstmt = conn.prepareStatement(sSqlDepartamento);
				rs = pstmt.executeQuery();
				// Linea0
				sLinea = "        <fo:table  >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" background-color=\"rgb(200,200,200)\" font-size=\"12pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Datos Generales
				sLinea = "	    <fo:table-cell border-style=\"solid\" background-color=\"rgb(200,200,200)\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"left\"  padding-top=\"0.2mm\">\n "
						+ res.getString("infHistoricoVeh.titulotabla2")
						+ "</fo:block>";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Linea1 Cabecera Tabla
				sLinea = "        <fo:table  space-after=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"100mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-header font-family=\"Helvetica\" font-size=\"8pt\" >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Primera Linea
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Código
				sLinea = "	    <fo:table-cell   border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col17")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Departamento
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col18")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Desde
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col19")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Hasta
				sLinea = "	    <fo:table-cell   border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col20")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-header>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				while (rs.next()) {
					sFecDesde = rs.getString(3) == null ? "" : rs.getString(3);
					sFecHasta = rs.getString(4) == null ? "" : rs.getString(4);
					sCodigo = rs.getString(1) == null ? "" : rs.getString(1);
					sDesDpto = rs.getString(2) == null ? "" : rs.getString(2);

					// Linea 1
					sLinea = "	    <fo:table-row >\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Código
					sLinea = "	    <fo:table-cell border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA[ "
							+ sCodigo + "]]></fo:block>";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Departamento
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
							+ sDesDpto + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Fecha Desde
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sFecDesde + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Fecha Hasta
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sFecHasta + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-row>\n";
					tmpFoFileStream.write(sLinea.getBytes());
				}
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				// SACAMOS SEGUROS
				if (pstmt != null) {
					rs.close();
					pstmt.close();
				}

				pstmt = conn.prepareStatement(sSqlSeguros);
				rs = pstmt.executeQuery();
				// Linea0
				sLinea = "        <fo:table >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" background-color=\"rgb(200,200,200)\" font-size=\"12pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Datos Generales
				sLinea = "	    <fo:table-cell border-style=\"solid\" background-color=\"rgb(200,200,200)\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"left\"  padding-top=\"0.2mm\">\n "
						+ res.getString("infHistoricoVeh.titulotabla3")
						+ "</fo:block>";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Linea1 Cabecera Tabla
				sLinea = "        <fo:table  space-after=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"40mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"40mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"30mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-header font-family=\"Helvetica\" font-size=\"8pt\" >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Primera Linea
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Póliza
				sLinea = "	    <fo:table-cell  border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col21")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Compañia
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col22")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Modalidad
				sLinea = "	    <fo:table-cell  border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col23")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Estado
				sLinea = "	    <fo:table-cell   border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col24")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-header>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				while (rs.next()) {
					sPoliza = rs.getString(2) == null ? "" : rs.getString(2);
					sCia = rs.getString(4) == null ? "" : rs.getString(4);
					sModalidad = rs.getString(5) == null ? "" : rs.getString(5);
					sEstado = rs.getString(6) == null ? "" : rs.getString(6);

					// Linea 1
					sLinea = "	    <fo:table-row >\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Póliza
					sLinea = "	    <fo:table-cell border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
							+ sPoliza + "]]></fo:block>";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Cia
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
							+ sCia + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Modalidad
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sModalidad + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Estado
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sEstado + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-row>\n";
					tmpFoFileStream.write(sLinea.getBytes());
				}
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				// SACAMOS TARJETAS
				if (pstmt != null) {
					rs.close();
					pstmt.close();
				}

				pstmt = conn.prepareStatement(sSqlTarjetas);
				rs = pstmt.executeQuery();
				// Linea0
				sLinea = "        <fo:table >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" background-color=\"rgb(200,200,200)\" font-size=\"12pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Datos Generales
				sLinea = "	    <fo:table-cell border-style=\"solid\" background-color=\"rgb(200,200,200)\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"left\"  padding-top=\"0.2mm\">\n "
						+ res.getString("infHistoricoVeh.titulotabla4")
						+ "</fo:block>";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Linea1 Cabecera Tabla
				sLinea = "        <fo:table  space-after=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"40mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"40mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"30mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-header font-family=\"Helvetica\" font-size=\"8pt\" >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Primera Linea
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Tarjetas
				sLinea = "	    <fo:table-cell  border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col25")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Entidad
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col26")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Nº de Cuenta
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col27")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Situación
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col28")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-header>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				while (rs.next()) {
					sTarjeta = rs.getString(2) == null ? "" : rs.getString(2);
					sEntidad = rs.getString(3) == null ? "" : rs.getString(3);
					sCuenta = rs.getString(4) == null ? "" : rs.getString(4);
					sSituacion = rs.getString(5) == null ? "" : rs.getString(5);

					// Linea 1
					sLinea = "	    <fo:table-row >\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Código
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
							+ sTarjeta + "]]></fo:block>";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Departamento
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
							+ sEntidad + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Fecha Desde
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sCuenta + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Fecha Hasta
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sSituacion + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-row>\n";
					tmpFoFileStream.write(sLinea.getBytes());
				}
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				// SACAMOS TASAS
				if (pstmt != null) {
					rs.close();
					pstmt.close();
				}

				pstmt = conn.prepareStatement(sSqlTasas);
				rs = pstmt.executeQuery();
				// Linea0
				sLinea = "        <fo:table >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" background-color=\"rgb(200,200,200)\" font-size=\"12pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Datos Generales
				sLinea = "	    <fo:table-cell border-style=\"solid\" background-color=\"rgb(200,200,200)\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"left\"  padding-top=\"0.2mm\">\n "
						+ res.getString("infHistoricoVeh.titulotabla5")
						+ "</fo:block>";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Linea1 Cabecera Tabla
				sLinea = "        <fo:table  space-after=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"90mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"30mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-header font-family=\"Helvetica\" font-size=\"8pt\" >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Primera Linea
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Concepto
				sLinea = "	    <fo:table-cell  border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col29")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Importe
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col30")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Fecha
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col31")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Municipio
				sLinea = "	    <fo:table-cell   border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col32")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-header>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				while (rs.next()) {
					sConcepto = rs.getString(2) == null ? "" : rs.getString(2);
					dNumero = rs.getDouble(3);
					sImporte = miComun.formatearDblMilesDec(dNumero);
					sFecDesde = rs.getString(4) == null ? "" : rs.getString(4);
					sMunicipio = rs.getString(5) == null ? "" : rs.getString(5);

					// Linea 1
					sLinea = "	    <fo:table-row >\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Concepto
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA[ "
							+ sConcepto + "]]></fo:block>";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Importe
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA[ "
							+ sImporte + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Fecha
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sFecDesde + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// FMunicipio
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sMunicipio + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-row>\n";
					tmpFoFileStream.write(sLinea.getBytes());
				}
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				// SACAMOS ORDENES
				if (pstmt != null) {
					rs.close();
					pstmt.close();
				}

				pstmt = conn.prepareStatement(sSqlOrdenes);
				rs = pstmt.executeQuery();
				// Linea0
				sLinea = "        <fo:table >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" background-color=\"rgb(200,200,200)\" font-size=\"12pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Datos Generales
				sLinea = "	    <fo:table-cell border-style=\"solid\" background-color=\"rgb(200,200,200)\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"left\"  padding-top=\"0.2mm\">\n "
						+ res.getString("infHistoricoVeh.titulotabla6")
						+ "</fo:block>";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Linea1 Cabecera Tabla
				sLinea = "        <fo:table  space-after=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"30mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"45mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"45mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				sLinea = "	    <fo:table-header font-family=\"Helvetica\" font-size=\"8pt\" >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Primera Linea
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Orden
				sLinea = "	    <fo:table-cell  border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col33")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Fecha
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col34")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Kms
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col35")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Taller
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col36")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Descripcion
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col37")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-header>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				while (rs.next()) {
					sOrden = rs.getString(2) == null ? "" : rs.getString(2);
					sFecDesde = rs.getString(3) == null ? "" : rs.getString(3);
					dNumeroS = (rs.getString(4) == null) ? "0" : rs
							.getString(4);
					sKilometros = miComun
							.formatearDblMiles(new Double(dNumeroS)
									.doubleValue());
					sKilometros = sKilometros.replaceAll(",", ".");
					sTaller = rs.getString(5) == null ? "" : rs.getString(5);
					sDescripcion = rs.getString(6) == null ? "" : rs
							.getString(6);
					;

					// Linea 1
					sLinea = "	    <fo:table-row >\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Orden
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA[ "
							+ sOrden + "]]></fo:block>";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Fecha
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
							+ sFecDesde + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Kilometros
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sKilometros + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Taller
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sTaller + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// Descripcion
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sDescripcion + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());

					sLinea = "	    </fo:table-row>\n";
					tmpFoFileStream.write(sLinea.getBytes());
				}
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				// SACAMOS Revisiones
				if (pstmt != null) {
					rs.close();
					pstmt.close();
				}

				pstmt = conn.prepareStatement(sSqlRevisiones);
				rs = pstmt.executeQuery();
				// Linea0
				sLinea = "        <fo:table >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" background-color=\"rgb(200,200,200)\" font-size=\"12pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Datos Generales
				sLinea = "	    <fo:table-cell border-style=\"solid\" background-color=\"rgb(200,200,200)\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"left\"  padding-top=\"0.2mm\">\n "
						+ res.getString("infHistoricoVeh.titulotabla7")
						+ "</fo:block>";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Linea1 Cabecera Tabla
				sLinea = "        <fo:table  space-after=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				sLinea = "	    <fo:table-header font-family=\"Helvetica\" font-size=\"8pt\" >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Primera Linea
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Fecha
				sLinea = "	    <fo:table-cell  border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col38")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Estado
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col39")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Resultado
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col40")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Fec. Repetición
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col41")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Fec. Próx. Insp.
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col42")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-header>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				while (rs.next()) {
					sFInsp = rs.getString(2) == null ? "" : rs.getString(2);
					sEstado = rs.getString(3) == null ? "" : rs.getString(3);
					sResultado = rs.getString(4) == null ? "" : rs.getString(4);
					sFRepet = rs.getString(5) == null ? "" : rs.getString(5);
					sFPInsp = rs.getString(6) == null ? "" : rs.getString(6);
					// Linea 1
					sLinea = "	    <fo:table-row >\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sFinsp
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
							+ sFInsp + "]]></fo:block>";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sEstado
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
							+ sEstado + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sResultado
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sResultado + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sFRepet
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sFRepet + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sFPInsp
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sFPInsp + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());

					sLinea = "	    </fo:table-row>\n";
					tmpFoFileStream.write(sLinea.getBytes());
				}
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				// SACAMOS Asignaciones
				if (pstmt != null) {
					rs.close();
					pstmt.close();
				}

				pstmt = conn.prepareStatement(sSqlAsignaciones);
				rs = pstmt.executeQuery();
				// Linea0
				sLinea = "        <fo:table >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" background-color=\"rgb(200,200,200)\" font-size=\"12pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Datos Generales
				sLinea = "	    <fo:table-cell border-style=\"solid\" background-color=\"rgb(200,200,200)\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"left\"  padding-top=\"0.2mm\">\n "
						+ res.getString("infHistoricoVeh.titulotabla8")
						+ "</fo:block>";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Linea1 Cabecera Tabla
				sLinea = "        <fo:table  space-after=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"70mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"70mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-header font-family=\"Helvetica\" font-size=\"8pt\" >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Primera Linea
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Dni
				sLinea = "	    <fo:table-cell  border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col43")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Nombre
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col44")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Rango
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col45")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-header>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				while (rs.next()) {
					sDni = rs.getString(2) == null ? "" : rs.getString(2);
					sNombre = rs.getString(3) == null ? "" : rs.getString(3);
					sDescripcion = rs.getString(4) == null ? "" : rs
							.getString(4);
					// Linea 1
					sLinea = "	    <fo:table-row >\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sFinsp
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
							+ sDni + "]]></fo:block>";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sEstado
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
							+ sNombre + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sResultado
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sDescripcion + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());

					sLinea = "	    </fo:table-row>\n";
					tmpFoFileStream.write(sLinea.getBytes());
				}
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				// SACAMOS Siniestros
				if (pstmt != null) {
					rs.close();
					pstmt.close();
				}

				pstmt = conn.prepareStatement(sSqlSiniestros);
				rs = pstmt.executeQuery();
				// Linea0
				sLinea = "        <fo:table >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" background-color=\"rgb(200,200,200)\" font-size=\"12pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Datos Generales
				sLinea = "	    <fo:table-cell border-style=\"solid\" background-color=\"rgb(200,200,200)\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"left\"  padding-top=\"0.2mm\">\n "
						+ res.getString("infHistoricoVeh.titulotabla9")
						+ "</fo:block>";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Linea1 Cabecera Tabla
				sLinea = "        <fo:table  space-after=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"46.5mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"46.5mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"47mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-header font-family=\"Helvetica\" font-size=\"8pt\" >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Primera Linea
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Fecha
				sLinea = "	    <fo:table-cell   border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col46")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Conductor
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col47")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Parte Contraria
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col48")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Responsabilidad
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col49")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-header>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				while (rs.next()) {
					sFecDesde = rs.getString(2) == null ? "" : rs.getString(2);
					sNombre = rs.getString(3) == null ? "" : rs.getString(3);
					sParteContraria = rs.getString(4) == null ? "" : rs
							.getString(4);
					sResponsabilidad = rs.getString(5) == null ? "" : rs
							.getString(5);

					// Linea 1
					sLinea = "	    <fo:table-row >\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sFecDesde
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
							+ sFecDesde + "]]></fo:block>";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sNombre
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
							+ sNombre + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sParteContraria
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sParteContraria + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sResponsabilidad
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sResponsabilidad + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-row>\n";
					tmpFoFileStream.write(sLinea.getBytes());
				}
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				// SACAMOS Sanciones
				if (pstmt != null) {
					rs.close();
					pstmt.close();
				}

				pstmt = conn.prepareStatement(sSqlSanciones);
				rs = pstmt.executeQuery();
				// Linea0
				sLinea = "        <fo:table >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" background-color=\"rgb(200,200,200)\" font-size=\"12pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Datos Generales
				sLinea = "	    <fo:table-cell border-style=\"solid\" background-color=\"rgb(200,200,200)\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"left\"  padding-top=\"0.2mm\">\n "
						+ res.getString("infHistoricoVeh.titulotabla10")
						+ "</fo:block>";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Linea1 Cabecera Tabla
				sLinea = "        <fo:table  space-after=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"20mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"100mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				sLinea = "	    <fo:table-header font-family=\"Helvetica\" font-size=\"8pt\" >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Primera Linea
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Código
				sLinea = "	    <fo:table-cell  border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col50")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Tipo
				sLinea = "	    <fo:table-cell  border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col51")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Fecha
				sLinea = "	    <fo:table-cell   border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col52")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Infractor
				sLinea = "	    <fo:table-cell   border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col53")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-header>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				while (rs.next()) {
					sCodigo = rs.getString(2) == null ? "" : rs.getString(2);
					sTipo = rs.getString(3) == null ? "" : rs.getString(3);
					sFecDesde = rs.getString(4) == null ? "" : rs.getString(4);
					sInfractor = rs.getString(5) == null ? "" : rs.getString(5);

					// Linea 1
					sLinea = "	    <fo:table-row >\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sCodigo
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
							+ sCodigo + "]]></fo:block>";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sTipo
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
							+ sTipo + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sFecha
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sFecDesde + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sInfractor
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sInfractor + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-row>\n";
					tmpFoFileStream.write(sLinea.getBytes());
				}
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());

				// SACAMOS GASTOS
				if (pstmt != null) {
					rs.close();
					pstmt.close();
				}

				pstmt = conn.prepareStatement(sSqlGastos);
				rs = pstmt.executeQuery();
				// Linea0
				sLinea = "        <fo:table >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" background-color=\"rgb(200,200,200)\" font-size=\"12pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Datos Generales
				sLinea = "	    <fo:table-cell border-style=\"solid\" background-color=\"rgb(200,200,200)\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block  text-align=\"left\"  padding-top=\"0.2mm\">\n "
						+ res.getString("infHistoricoVeh.titulotabla11")
						+ "</fo:block>";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Linea1 Cabecera Tabla
				sLinea = "        <fo:table  space-after=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"55mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"55mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-column column-width=\"50mm\"/>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-header font-family=\"Helvetica\" font-size=\"8pt\" >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Primera Linea
				sLinea = "	    <fo:table-row >\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Tarjeta
				sLinea = "	    <fo:table-cell  border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col54")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Tipo
				sLinea = "	    <fo:table-cell    border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col55")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				// Importe
				sLinea = "	    <fo:table-cell   border-style=\"solid\" padding-top=\"0.2mm\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "      <fo:block font-weight=\"bold\"  text-align=\"center\"  >\n "
						+ res.getString("infHistoricoVeh.col56")
						+ "</fo:block>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-cell>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-row>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    </fo:table-header>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "	    <fo:table-body font-family=\"Helvetica\" font-size=\"8pt\">\n";
				tmpFoFileStream.write(sLinea.getBytes());
				while (rs.next()) {
					sTarjeta = rs.getString(2) == null ? "" : rs.getString(2);
					sTipo = rs.getString(3) == null ? "" : rs.getString(3);
					dNumero = rs.getDouble(4);
					sImporte = miComun.formatearDblMilesDec(dNumero);

					// Linea 1
					sLinea = "	    <fo:table-row >\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sTarjeta
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["+ sTarjeta + "]]></fo:block>";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sTipo
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n <![CDATA["
							+ sTipo + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					// sImporte
					sLinea = "	    <fo:table-cell  border-style=\"solid\">\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "      <fo:block  text-align=\"center\" padding-top=\"0.2mm\">\n<![CDATA["
							+ sImporte + "]]></fo:block>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-cell>\n";
					tmpFoFileStream.write(sLinea.getBytes());
					sLinea = "	    </fo:table-row>\n";
					tmpFoFileStream.write(sLinea.getBytes());
				}
				sLinea = "	    </fo:table-body>\n";
				tmpFoFileStream.write(sLinea.getBytes());
				sLinea = "       </fo:table>\n";
				tmpFoFileStream.write(sLinea.getBytes());

			}
			rs.close();
			// sLinea = "      </fo:block-container>\n";
			// tmpFoFileStream.write(sLinea.getBytes());

			sLinea = "      </fo:flow>\n";
			tmpFoFileStream.write(sLinea.getBytes());

			sLinea = "   </fo:page-sequence>\n";
			tmpFoFileStream.write(sLinea.getBytes());

			sLinea = "</fo:root>\n";
			tmpFoFileStream.write(sLinea.getBytes());

			tmpFoFileStream.close();

			generarPDFdesdeFO(sFoFileDir + tmpFoFile.getName(), sFoFileDir,
					response);
			// FileInputStream file = new FileInputStream(sFoFileDir +
			// tmpFoFile.getName());

			// renderFO(new InputSource(file), response);

			// tmpFoFile.delete();

			// response.flushBuffer();

		} catch (Exception ex) {
			miLog.addTraza(ex);
			try {
				response.sendRedirect("m05bError.jsp");
			} catch (IOException e) {
				// TODO Auto-generated catch block
				miLog.addTraza(e);
			}
		} finally {
			try {
				if (rs != null)
					rs.close();
				if (pstmt != null)
					pstmt.close();
				if (conn != null)
					conn.close();
			} catch (SQLException e2) {
				miLog.addTraza(e2);
				try {
					response.sendRedirect("m05bError.jsp");
				} catch (IOException e) {
					// TODO Auto-generated catch block
					miLog.addTraza(e);
				}
			}
		}
	}

	/**
	 * renders an FO inputsource into a PDF file which is rendered directly to
	 * the response object's OutputStream
	 */
	public void renderFO(InputSource foFile, HttpServletResponse response)
			throws ServletException {
		try {
			ByteArrayOutputStream out = new ByteArrayOutputStream();

			response.reset();
			OutputStream oOut = response.getOutputStream();
			BufferedOutputStream bOut = new BufferedOutputStream(oOut);
			Driver driver = new Driver(foFile, out);
			driver.setRenderer(Driver.RENDER_PDF);
			driver.run();

			response.setContentLength(out.size());
			response.setContentType("application/pdf");

			bOut.write(out.toByteArray());
			out.close();
			bOut.flush();
			bOut.close();
			// response.flushBuffer();
		} catch (Exception ex) {
			miLog.addTraza(ex);
			throw new ServletException(ex);
		}
	}

	public void generarPDFdesdeFO(String ficheroFO, String rutaPDF,
			HttpServletResponse response) throws FOPException {
		try {

			Driver driver = new Driver();

			driver.setRenderer(Driver.RENDER_PDF);

			// Si no existe el directrio lo crea
			File f = new File(rutaPDF);

			if (!f.exists()) {

				f.mkdir();

			}
			// Cargar los datos del .FO
			FileInputStream file = new FileInputStream(ficheroFO);

			BufferedInputStream bfile = new BufferedInputStream(file);

			driver.setInputSource(new InputSource(bfile));

			// Crear un temporal que va a ser el .pdf
			String sPdfFileDir = rutaPDF;
			File pdfFileDir = new File(sPdfFileDir);
			File tmpPdfFile = File.createTempFile("m05b", ".pdf", pdfFileDir);

			FileOutputStream fileout = new FileOutputStream(tmpPdfFile);

			BufferedOutputStream bfileout = new BufferedOutputStream(fileout);

			driver.setOutputStream(bfileout);

			driver.run();

			bfile.close();

			bfileout.close();
			// Longitus del Fichero PDF.
			Long longitud = new Long(tmpPdfFile.length());
			String sLongitud = "" + longitud;
			int iLongitud = Integer.parseInt(sLongitud);

			response.setContentLength((int) iLongitud);
			response.setContentType("application/pdf");

			byte[] fileBytes = new byte[longitud.intValue()];
			FileInputStream fisficheroPdf = new FileInputStream(tmpPdfFile);
			fisficheroPdf.read(fileBytes);
			ServletOutputStream os = response.getOutputStream();
			((OutputStream) os).write(fileBytes);
			((OutputStream) os).flush();
			((OutputStream) os).close();

			// BORRAR EL FICHERO FO

			File fichero = new File(ficheroFO);

			boolean borrado = fichero.delete();
			boolean borrado2 = tmpPdfFile.delete();

		} catch (Exception e) {

			// System.out.println("EXCEPCION !!! : Error pasando de FO a PDF: "
			// + e);

		}

	}

}