/* * Metodo que imprime una lista de turnos directamente en una impresra byte */ public void printLista(List<CexHorariosDia> listaTurno) throws IOException { // FileInputStream inputStream = null; InputStream tex = null; SimpleDateFormat sf = new SimpleDateFormat("dd/MM/yyyy"); String fecha; SimpleDateFormat sfHora = new SimpleDateFormat("HH:mm"); String hora = ""; String te2; DocFlavor docFormat; Doc document; DocPrintJob printJob; PrintService impresora11 = null; String impresora = "SIN IMPRESORA"; for (CexHorariosDia horD : listaTurno) { for (CexAgenda turno : horD.getCexAgendaList()) { if (turno.isSeleccionado()) { fecha = sf.format(turno.getCagFecha()); try { if (turno.getCagHora() != null) { hora = sfHora.format(turno.getCagHora()); } // inputStream = new FileInputStream("e:/archivo.txt"); String cadena = "************************************* \n\n" + "RESPONSABLE: " + turno.getCagNombreUsuario() + " \n" + "FECHA: " + fecha + " \n" + turno.getCagNombreInstitucion() + "\n" + turno .getCexHorariosDia() .getCexHorario() .getCexEspecialidadMedico() .getCexEspecialidad() .getCesNombre() + "\n" + "NÚMERO CARPETA: " + turno.getHosReferencia() != null ? turno.getHosReferencia().getCexHistoriaInstitucion().getCicNumeroCarpeta() : turno.getCexHistoriaInstitucion().getCicNumeroCarpeta() + "\n" + "CÉDULA: " + turno.getHosReferencia() != null ? turno .getHosReferencia() .getCexHistoriaInstitucion() .getCexHistoriaClinica() .getChcCedula() : turno.getCexHistoriaInstitucion().getCexHistoriaClinica().getChcCedula() + "\n" + "TURNO: " + turno.getCagSecuencia() + "\t HORA: " + hora + " \n" + "MEDICO: " + turno .getCexHorariosDia() .getCexHorario() .getCexEspecialidadMedico() .getAdmMedico() .getAmeNombreFull() + "\n" + "PACIENTE: " + turno.getHosReferencia() != null ? turno .getHosReferencia() .getCexHistoriaInstitucion() .getCexHistoriaClinica() .getChcNombreFull() : turno .getCexHistoriaInstitucion() .getCexHistoriaClinica() .getChcNombreFull() + "\n" + "***************************************\n" + "\n" + "\n" + "SE RECOMIENDA ESTAR 30 MIN ANTES\n" + " DE LA HORA ESPECIFICADA\n" + "\n"; te2 = converteCaracter(cadena); tex = new ByteArrayInputStream(te2.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { log.error("printExtra() {} ", e.getMessage()); } if (tex == null) { return; } docFormat = DocFlavor.INPUT_STREAM.AUTOSENSE; document = new SimpleDoc(tex, docFormat, null); PrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet(); for (AdmDatosGlobales datoGlobal : listaImpresorasturnos) { if (user.getIp().equals(datoGlobal.getClave())) { impresora = datoGlobal.getValor(); break; } } // impresora11 = PrintServiceLookup.lookupDefaultPrintService(); PrintService[] printService = PrintServiceLookup.lookupPrintServices(null, null); for (PrintService printService1 : printService) { if (printService1.getName().equals(impresora)) { impresora11 = printService1; } } if (impresora11 != null) { printJob = impresora11.createPrintJob(); try { printJob.print(document, attributeSet); } catch (PrintException e) { log.error("printExtra() {} ", e.getMessage()); } } else { log.error("No existen impresoras instaladas"); for (PrintService printService1 : printService) { log.error(printService1.getName()); } } tex.close(); } } } }