// <editor-fold defaultstate="collapsed" desc="void imprimir() ">
public void imprimir() {
com.lowagie.text.Document document = new com.lowagie.text.Document(PageSize.A4.rotate());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
PdfWriter.getInstance(document, baos);
//METADATA
document.open();
document.add(ReportUtils.paragraph("PROGRAMACION DE FLOTA VEHICULAR", FontFactory.getFont("arial", 12, Font.BOLD), Element.ALIGN_CENTER));
Date currentDate = new Date();
String date = DateUtil.showDate(currentDate) + " " + DateUtil.showHour(currentDate);
document.add(ReportUtils.paragraph("Fecha: " + date, FontFactory.getFont("arial", 10, Font.BOLD), Element.ALIGN_RIGHT));
document.add(new Paragraph("\n"));
//Numero de columnas
PdfPTable table = new PdfPTable(8);
//Aqui indicamos el tamaño de cada columna
table.setTotalWidth(new float[]{85, 65, 85, 80, 85, 220, 72, 105});
table.setLockedWidth(true);
table.addCell(ReportUtils.PdfCell("Partida", FontFactory.getFont("arial", 11, Font.BOLD), Element.ALIGN_CENTER));
table.addCell(ReportUtils.PdfCell("Dia", FontFactory.getFont("arial", 11, Font.BOLD), Element.ALIGN_CENTER));
table.addCell(ReportUtils.PdfCell("Regreso", FontFactory.getFont("arial", 11, Font.BOLD), Element.ALIGN_CENTER));
table.addCell(ReportUtils.PdfCell("Unidad", FontFactory.getFont("arial", 11, Font.BOLD), Element.ALIGN_CENTER));
table.addCell(ReportUtils.PdfCell("Solicitado", FontFactory.getFont("arial", 11, Font.BOLD), Element.ALIGN_CENTER));
table.addCell(ReportUtils.PdfCell("Mision", FontFactory.getFont("arial", 11, Font.BOLD), Element.ALIGN_CENTER));
table.addCell(ReportUtils.PdfCell("Conductor", FontFactory.getFont("arial", 11, Font.BOLD), Element.ALIGN_CENTER));
table.addCell(ReportUtils.PdfCell("Vehiculo", FontFactory.getFont("arial", 11, Font.BOLD), Element.ALIGN_CENTER));
for (ProgramacionVehicular pv : programacionVehicular) {
String fechaPartida = DateUtil.showDate(pv.getFechahorasalida()) + " " + DateUtil.showHour(pv.getFechahorasalida());
String fechaRegreso = DateUtil.showDate(pv.getFechahoraregreso()) + " " + DateUtil.showHour(pv.getFechahoraregreso());
String fechaSolicitado = DateUtil.showDate(pv.getFechasolicitud()) + " " + DateUtil.showHour(pv.getFechasolicitud());
table.addCell(ReportUtils.PdfCell(fechaPartida, FontFactory.getFont("arial", 9, Font.NORMAL)));
table.addCell(ReportUtils.PdfCell(pv.getNombredia(), FontFactory.getFont("arial", 9, Font.NORMAL)));
table.addCell(ReportUtils.PdfCell(fechaRegreso, FontFactory.getFont("arial", 9, Font.NORMAL)));
table.addCell(ReportUtils.PdfCell(pv.getUnidad(), FontFactory.getFont("arial", 9, Font.NORMAL)));
table.addCell(ReportUtils.PdfCell(fechaSolicitado, FontFactory.getFont("arial", 9, Font.NORMAL)));
table.addCell(ReportUtils.PdfCell(pv.getMision(), FontFactory.getFont("arial", 9, Font.NORMAL)));
table.addCell(ReportUtils.PdfCell(pv.getConductor(), FontFactory.getFont("arial", 9, Font.NORMAL)));
table.addCell(ReportUtils.PdfCell(pv.getMarca() + " " + pv.getModelo() + " PLACA:" + pv.getPlaca(), FontFactory.getFont("arial", 9, Font.NORMAL)));
}
document.add(table);
} catch (Exception ex) {
System.out.println("Error " + ex.getMessage());
}
document.close();
ReportUtils.printPDF(baos);
}
// </editor-fold>