List of usage examples for com.itextpdf.text.pdf PdfPTable PdfPTable
public PdfPTable(final PdfPTable table)
PdfPTable
. From source file:com.devox.GUI.PDF.CrearReportePorEstado.java
@Override public PdfPTable crearTabla() { PdfPTable table = new PdfPTable(2); PdfPCell cell;//from w ww . j a v a 2 s .co m cell = new PdfPCell(new Phrase("FOLIO DHL", FUENTE_CABECERA_TABLA_MEDIANA)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorRight(GRIS_CLARO); cell.setFixedHeight(20f); table.addCell(cell); cell = new PdfPCell(new Phrase("DESTINO", FUENTE_CABECERA_TABLA_MEDIANA)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); return table; }
From source file:com.devox.GUI.PDF.CrearReporteTarimas.java
@Override public PdfPTable configurarInformacion() { PdfPTable table = new PdfPTable(2); try {/* w ww . j a v a2s . co m*/ PdfPCell cell; Phrase tarima = new Phrase(); tarima.add(new Chunk("TARIMA\n", FUENTE_TARIMA_NEGRO)); tarima.add(new Chunk(datosTarima.getNombreTarima(), FUENTE_TARIMA_ROJO)); cell = new PdfPCell(tarima); cell.setRowspan(5); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); cell.setFixedHeight(200f); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("DIVISIN ", datosTarima.getDivision())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("ALMACN ", datosTarima.getAlmacen())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("FECHA DE APERTURA ", Funciones.getOtherDate(datosTarima.getFecha_Apertura()))); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("FECHA DE CIERRE ", (datosTarima.getFecha_Cierra() == null ? "TARIMA ABIERTA" : Funciones.getOtherDate(datosTarima.getFecha_Cierra())))); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("DESTRUCCIN FISCAL ", Integer.toString(datosTarima.getDestruccionFiscal()))); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); table.setWidthPercentage(100); table.setWidths(new int[] { 2, 1 }); } catch (DocumentException de) { Log.print(de); } return table; }
From source file:com.devox.GUI.PDF.CrearReporteTarimas.java
@Override public PdfPTable crearTabla() { PdfPTable table = new PdfPTable(4); PdfPCell cell;//from w ww .j a va2s . co m cell = new PdfPCell(new Phrase("FOLIO DHL", FUENTE_CABECERA_TABLA_MEDIANA)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorRight(GRIS_CLARO); cell.setFixedHeight(20f); table.addCell(cell); cell = new PdfPCell(new Phrase("PRODUCTO (Descripcin)", FUENTE_CABECERA_TABLA_MEDIANA)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); cell = new PdfPCell(new Phrase("CDIGO INTERNO", FUENTE_CABECERA_TABLA_MEDIANA)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); cell = new PdfPCell(new Phrase("CANTIDAD", FUENTE_CABECERA_TABLA_MEDIANA)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); try { table.setWidths(new float[] { 1f, 1.5f, 2.5f, 1f }); table.setWidthPercentage(100); } catch (DocumentException ex) { Log.print(ex); } return table; }
From source file:com.devox.GUI.PDF.ExportarAPDF.java
private static PdfPTable setUpInformation() { PdfPTable table = new PdfPTable(2); try {// w w w .jav a2 s. co m PdfPCell cell; Phrase folio = new Phrase(); folio.add(new Chunk("FOLIO DHL ", font_foliodhl)); folio.add(new Chunk(contenido.getFolioDHL(), font_folionum)); cell = new PdfPCell(folio); cell.setRowspan(8); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("Cliente ", contenido.getNombreCliente())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("Nmero de cliente ", contenido.getClaveCliente())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("Folio del cliente ", contenido.getFolioCliente())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("Folio Abbott ", contenido.getFolioAbbott())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("Motivo de devolucin ", contenido.getMotivo().getCodigo() + " - " + contenido.getMotivo().getDescripcion())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("Factura ", contenido.getFactura())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("Almacn ", contenido.getAlmacen())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell( getPhraseFromChunks("Fecha de captura ", Funciones.getOtherDate(contenido.getFechaCaptura()))); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); table.setWidthPercentage(100); table.setWidths(new int[] { 1, 3 }); } catch (DocumentException ex) { Log.print(ex); Log.print(ex); } return table; }
From source file:com.devox.GUI.PDF.ExportarAPDF.java
private static PdfPTable createTable() { PdfPTable table = new PdfPTable(6); PdfPCell cell;//from ww w . ja v a 2 s.c o m cell = new PdfPCell(new Phrase("DESCRIPCIN", font_headertable1)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorRight(GRIS_CLARO); cell.setFixedHeight(20f); table.addCell(cell); cell = new PdfPCell(new Phrase("LOTE", font_headertable1)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); cell = new PdfPCell(new Phrase("CDIGO", font_headertable1)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); cell = new PdfPCell(new Phrase("CANTIDAD", font_headertable1)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); cell = new PdfPCell(new Phrase("PRECIO UNITARIO", font_headertable1)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); cell = new PdfPCell(new Phrase("SUBTOTAL", font_headertable1)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(AMARILLO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); try { table.setWidths(new float[] { 5f, 2f, 3f, 1.2f, 1.4f, 1.5f }); table.setWidthPercentage(98); } catch (DocumentException ex) { Log.print(ex); Log.print(ex); } return table; }
From source file:com.devox.GUI.PDF.ExportarAPDF.java
private static PdfPTable createSigningTable() { PdfPTable table = new PdfPTable(4); PdfPCell cell;//from w w w. j a v a 2 s . c o m cell = new PdfPCell(new Phrase("RMA", font_headertable2)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorRight(GRIS_CLARO); cell.setFixedHeight(25f); table.addCell(cell); cell = new PdfPCell(new Phrase("ORDEN", font_headertable2)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); cell = new PdfPCell(new Phrase("ELABOR", font_headertable2)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); cell = new PdfPCell(new Phrase("DICTAMIN QA", font_headertable2)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); cell = new PdfPCell(new Phrase(" ")); cell.setFixedHeight(50f); for (int i = 0; i < 4; i++) { table.addCell(cell); } cell = new PdfPCell(new Phrase(" ")); cell.setFixedHeight(25f); cell.setBackgroundColor(GRIS_CLARO); for (int i = 0; i < 2; i++) { table.addCell(cell); } cell = new PdfPCell(new Phrase("NOMBRE Y FIRMA", font_table)); cell.setFixedHeight(25f); cell.setBackgroundColor(GRIS_CLARO); for (int i = 0; i < 2; i++) { table.addCell(cell); } table.setTotalWidth(500); return table; }
From source file:com.devox.GUI.PDF.ExportarAPDF.java
private PdfPTable setUpInformationTarimas() { PdfPTable table = new PdfPTable(2); try {//w w w.j a v a 2 s . c o m PdfPCell cell; Phrase tarima = new Phrase(); tarima.add(new Chunk("TARIMA\n", font_tarimota)); tarima.add(new Chunk(datosTarima.getNombreTarima(), font_tarimota_gris)); cell = new PdfPCell(tarima); cell.setRowspan(5); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); cell.setFixedHeight(200f); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("DIVISIN ", datosTarima.getDivision())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("ALMACN ", datosTarima.getAlmacen())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("FECHA DE APERTURA ", Funciones.getOtherDate(datosTarima.getFecha_Apertura()))); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell( getPhraseFromChunks("FECHA DE CIERRE ", Funciones.getOtherDate(datosTarima.getFecha_Cierra()))); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("DESTRUCCIN FISCAL ", Integer.toString(datosTarima.getDestruccionFiscal()))); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); table.setWidthPercentage(100); table.setWidths(new int[] { 2, 1 }); } catch (DocumentException de) { Log.print(de); } return table; }
From source file:com.devox.GUI.PDF.ExportarAPDF.java
private PdfPTable createTableTarimas() { PdfPTable table = new PdfPTable(4); PdfPCell cell;/*from w ww . j ava 2s . co m*/ cell = new PdfPCell(new Phrase("FOLIO DHL", font_headertable1)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorRight(GRIS_CLARO); cell.setFixedHeight(20f); table.addCell(cell); cell = new PdfPCell(new Phrase("PRODUCTO (Descripcin)", font_headertable1)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); cell = new PdfPCell(new Phrase("CDIGO INTERNO", font_headertable1)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); cell = new PdfPCell(new Phrase("CANTIDAD", font_headertable1)); cell.setBackgroundColor(AMARILLO); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderColorLeft(GRIS_CLARO); cell.setBorderColorRight(GRIS_CLARO); cell.setBorderColorTop(AMARILLO); table.addCell(cell); try { table.setWidths(new float[] { 1f, 1.5f, 2.5f, 1f }); table.setWidthPercentage(100); } catch (DocumentException ex) { Log.print(ex); Log.print(ex); } return table; }
From source file:com.dexter.fms.mbean.ReportsMBean.java
@SuppressWarnings("unchecked") public void createPDF(int type, String filename, int pageType) { try {/* w w w .j a v a 2s. c o m*/ FacesContext context = FacesContext.getCurrentInstance(); Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter.getInstance(document, baos); writer.setPageEvent(new HeaderFooter()); writer.setBoxSize("footer", new Rectangle(36, 54, 559, 788)); if (!document.isOpen()) { document.open(); } switch (pageType) { case 1: document.setPageSize(PageSize.A4); break; case 2: document.setPageSize(PageSize.A4.rotate()); break; } document.addAuthor("FMS"); document.addCreationDate(); document.addCreator("FMS"); document.addSubject("Report"); document.addTitle(getReport_title()); PdfPTable headerTable = new PdfPTable(1); ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext() .getContext(); String logo = servletContext.getRealPath("") + File.separator + "resources" + File.separator + "images" + File.separator + "satraklogo.jpg"; Hashtable<String, Object> params = new Hashtable<String, Object>(); params.put("partner", dashBean.getUser().getPartner()); GeneralDAO gDAO = new GeneralDAO(); Object pSettingsObj = gDAO.search("PartnerSetting", params); PartnerSetting setting = null; if (pSettingsObj != null) { Vector<PartnerSetting> pSettingsList = (Vector<PartnerSetting>) pSettingsObj; for (PartnerSetting e : pSettingsList) { setting = e; } } gDAO.destroy(); PdfPCell c = null; if (setting != null && setting.getLogo() != null) { Image logoImg = Image.getInstance(setting.getLogo()); logoImg.scaleToFit(212, 51); c = new PdfPCell(logoImg); } else c = new PdfPCell(Image.getInstance(logo)); c.setBorder(0); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); headerTable.addCell(c); Paragraph stars = new Paragraph(20); stars.add(Chunk.NEWLINE); stars.setSpacingAfter(20); c = new PdfPCell(stars); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setBorder(0); headerTable.addCell(c); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { //font exception } Font font = new Font(helvetica, 16, Font.NORMAL | Font.BOLD); c = new PdfPCell(new Paragraph(getReport_title(), font)); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setBorder(0); headerTable.addCell(c); if (getReport_start_dt() != null && getReport_end_dt() != null) { stars = new Paragraph(20); stars.add(Chunk.NEWLINE); stars.setSpacingAfter(10); c = new PdfPCell(stars); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setBorder(0); headerTable.addCell(c); new Font(helvetica, 12, Font.NORMAL); Paragraph ch = new Paragraph("From " + getReport_start_dt() + " to " + getReport_end_dt(), font); c = new PdfPCell(ch); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); headerTable.addCell(c); } stars = new Paragraph(20); stars.add(Chunk.NEWLINE); stars.setSpacingAfter(20); c = new PdfPCell(stars); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setBorder(0); headerTable.addCell(c); document.add(headerTable); PdfPTable pdfTable = exportPDFTable(type); if (pdfTable != null) document.add(pdfTable); //Keep modifying your pdf file (add pages and more) document.close(); String fileName = filename + ".pdf"; writeFileToResponse(context.getExternalContext(), baos, fileName, "application/pdf"); context.responseComplete(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.dexter.fms.mbean.ReportsMBean.java
@SuppressWarnings("deprecation") private PdfPTable exportPDFTable(int type) { int numberOfColumns = 0; PdfPTable pdfTable = null;/*from ww w . j a va 2 s . c om*/ switch (type) { case 1: // all users report { numberOfColumns = 7; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("User name", font)); pdfTable.addCell(new Paragraph("Full name", font)); pdfTable.addCell(new Paragraph("Email", font)); pdfTable.addCell(new Paragraph("Department", font)); pdfTable.addCell(new Paragraph("Region", font)); pdfTable.addCell(new Paragraph("Phone", font)); pdfTable.addCell(new Paragraph("Position", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getAllUsers() != null) { for (PartnerUser e : getAllUsers()) { pdfTable.addCell(new Paragraph(e.getUsername(), font)); pdfTable.addCell(new Paragraph( e.getPersonel().getFirstname() + " " + e.getPersonel().getLastname(), font)); pdfTable.addCell(new Paragraph(e.getPersonel().getEmail(), font)); pdfTable.addCell(new Paragraph( (e.getPersonel().getDepartment() != null) ? e.getPersonel().getDepartment().getName() : "N/A", font)); pdfTable.addCell(new Paragraph( (e.getPersonel().getRegion() != null) ? e.getPersonel().getRegion().getName() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getPersonel().getPhone(), font)); pdfTable.addCell(new Paragraph(e.getPersonel().getPosition(), font)); } } break; } case 2: // due driver's license { numberOfColumns = 6; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Full Name", font)); pdfTable.addCell(new Paragraph("Dept", font)); pdfTable.addCell(new Paragraph("Region", font)); pdfTable.addCell(new Paragraph("Phone", font)); pdfTable.addCell(new Paragraph("Position", font)); pdfTable.addCell(new Paragraph("License Due Date", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getDueDriversLic() != null) { for (DriverLicense e : getDueDriversLic()) { pdfTable.addCell(new Paragraph(e.getDriver().getPersonel().getFirstname() + " " + e.getDriver().getPersonel().getLastname(), font)); pdfTable.addCell(new Paragraph(e.getDriver().getPersonel().getDepartment() != null ? e.getDriver().getPersonel().getDepartment().getName() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getDriver().getPersonel().getRegion() != null ? e.getDriver().getPersonel().getRegion().getName() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getDriver().getPersonel().getPhone(), font)); pdfTable.addCell(new Paragraph(e.getDriver().getPersonel().getPosition(), font)); pdfTable.addCell(new Paragraph(e.getLic_end_dt().toLocaleString(), font)); } } break; } case 3: // accidents { numberOfColumns = 8; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Accident Date", font)); pdfTable.addCell(new Paragraph("Description", font)); pdfTable.addCell(new Paragraph("Driver", font)); pdfTable.addCell(new Paragraph("Driver Comment", font)); pdfTable.addCell(new Paragraph("Police Officer", font)); pdfTable.addCell(new Paragraph("Police Station", font)); pdfTable.addCell(new Paragraph("Police Comment", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getVehicleAccidents() != null) { for (VehicleAccident e : getVehicleAccidents()) { pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font)); pdfTable.addCell(new Paragraph(e.getAccident_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getAccidentDescription(), font)); pdfTable.addCell(new Paragraph(e.getDriver_name(), font)); pdfTable.addCell(new Paragraph(e.getDriverComment(), font)); pdfTable.addCell(new Paragraph(e.getPoliceOfficer(), font)); pdfTable.addCell(new Paragraph(e.getPoliceStation(), font)); pdfTable.addCell(new Paragraph(e.getPoliceComment(), font)); } } break; } case 4: // vehicles by brand { numberOfColumns = 4; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Make", font)); pdfTable.addCell(new Paragraph("Model", font)); pdfTable.addCell(new Paragraph("Year", font)); pdfTable.addCell(new Paragraph("Reg No.", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getVehiclesByBrand() != null) { for (Vehicle e : getVehiclesByBrand()) { pdfTable.addCell(new Paragraph(e.getModel().getMaker().getName(), font)); pdfTable.addCell(new Paragraph(e.getModel().getName(), font)); pdfTable.addCell(new Paragraph(e.getModel().getYear(), font)); pdfTable.addCell(new Paragraph(e.getRegistrationNo(), font)); } } break; } case 5: // routine maintenance { numberOfColumns = 8; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Requester", font)); pdfTable.addCell(new Paragraph("Description", font)); pdfTable.addCell(new Paragraph("Start Date", font)); pdfTable.addCell(new Paragraph("Initial Cost", font)); pdfTable.addCell(new Paragraph("Status", font)); pdfTable.addCell(new Paragraph("Close Date", font)); pdfTable.addCell(new Paragraph("Final Cost", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getRmaints() != null) { for (VehicleRoutineMaintenance e : getRmaints()) { pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font)); pdfTable.addCell(new Paragraph(e.getCreatedBy().getPersonel().getFirstname() + " " + e.getCreatedBy().getPersonel().getLastname(), font)); pdfTable.addCell(new Paragraph(e.getDescription(), font)); pdfTable.addCell(new Paragraph(e.getStart_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getInitial_amount().toPlainString(), font)); pdfTable.addCell(new Paragraph(e.getStatus(), font)); pdfTable.addCell(new Paragraph(e.getClose_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getClosed_amount().toPlainString(), font)); } } break; } case 6: // ad hoc maintenance { numberOfColumns = 8; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Requester", font)); pdfTable.addCell(new Paragraph("Description", font)); pdfTable.addCell(new Paragraph("Start Date", font)); pdfTable.addCell(new Paragraph("Initial Cost", font)); pdfTable.addCell(new Paragraph("Status", font)); pdfTable.addCell(new Paragraph("Close Date", font)); pdfTable.addCell(new Paragraph("Final Cost", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getAdhocmaints() != null) { for (VehicleAdHocMaintenance e : getAdhocmaints()) { pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font)); pdfTable.addCell(new Paragraph(e.getCreatedBy().getPersonel().getFirstname() + " " + e.getCreatedBy().getPersonel().getLastname(), font)); pdfTable.addCell(new Paragraph(e.getDescription(), font)); pdfTable.addCell(new Paragraph(e.getStart_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getInitial_cost().toPlainString(), font)); pdfTable.addCell(new Paragraph(e.getStatus(), font)); pdfTable.addCell(new Paragraph(e.getClose_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getClosed_cost().toPlainString(), font)); } } break; } case 7: // active accidents { numberOfColumns = 8; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Accident Date", font)); pdfTable.addCell(new Paragraph("Description", font)); pdfTable.addCell(new Paragraph("Driver Name", font)); pdfTable.addCell(new Paragraph("Driver Comment", font)); pdfTable.addCell(new Paragraph("Police Name", font)); pdfTable.addCell(new Paragraph("Station Name", font)); pdfTable.addCell(new Paragraph("Police Comment", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getActiveAccidents() != null) { for (VehicleAccident e : getActiveAccidents()) { pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font)); pdfTable.addCell(new Paragraph(e.getAccident_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getAccidentDescription(), font)); pdfTable.addCell(new Paragraph(e.getDriver_name(), font)); pdfTable.addCell(new Paragraph(e.getDriverComment(), font)); pdfTable.addCell(new Paragraph(e.getPoliceOfficer(), font)); pdfTable.addCell(new Paragraph(e.getPoliceStation(), font)); pdfTable.addCell(new Paragraph(e.getPoliceComment(), font)); } } break; } case 8: // coporate trips { numberOfColumns = 9; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 6, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Requester", font)); pdfTable.addCell(new Paragraph("Department", font)); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Departure Location", font)); pdfTable.addCell(new Paragraph("Arrival Location", font)); pdfTable.addCell(new Paragraph("Departure Date and Time", font)); pdfTable.addCell(new Paragraph("Est. Arrival Date and Time", font)); pdfTable.addCell(new Paragraph("Act. Arrival Date and Time", font)); pdfTable.addCell(new Paragraph("Status", font)); font = new Font(helvetica, 6, Font.NORMAL); if (getCorTrips() != null) { for (CorporateTrip e : getCorTrips()) { pdfTable.addCell( new Paragraph(e.getStaff().getFirstname() + " " + e.getStaff().getLastname(), font)); pdfTable.addCell(new Paragraph( (e.getStaff().getDepartment() != null) ? e.getStaff().getDepartment().getName() : "N/A", font)); pdfTable.addCell(new Paragraph( e.getVehicle() != null ? e.getVehicle().getRegistrationNo() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getDepartureLocation(), font)); pdfTable.addCell(new Paragraph(e.getArrivalLocation(), font)); pdfTable.addCell(new Paragraph(e.getDepartureDateTime().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getEstimatedArrivalDateTime().toLocaleString(), font)); pdfTable.addCell(new Paragraph( e.getCompleteRequestDateTime() != null ? e.getCompleteRequestDateTime().toLocaleString() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getTripStatus(), font)); } } break; } case 9: // expense report { numberOfColumns = 4; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Type", font)); pdfTable.addCell(new Paragraph("Date", font)); pdfTable.addCell(new Paragraph("Amount", font)); pdfTable.addCell(new Paragraph("Detail", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getExpenses() != null) { for (Expense e : getExpenses()) { pdfTable.addCell(new Paragraph(e.getType().getName(), font)); pdfTable.addCell(new Paragraph(e.getExpense_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph("" + e.getAmount(), font)); pdfTable.addCell(new Paragraph(e.getRemarks(), font)); } } break; } case 10: // vehicle ages { numberOfColumns = 6; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Make", font)); pdfTable.addCell(new Paragraph("Model", font)); pdfTable.addCell(new Paragraph("Year", font)); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Date of Purchase", font)); pdfTable.addCell(new Paragraph("Age (in years)", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getVehiclesAges() != null) { for (Vehicle e : getVehiclesAges()) { pdfTable.addCell(new Paragraph( e.getModel().getMaker() != null ? e.getModel().getMaker().getName() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getModel() != null ? e.getModel().getName() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getModel() != null ? e.getModel().getYear() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getRegistrationNo(), font)); pdfTable.addCell(new Paragraph( e.getPurchaseDate() != null ? e.getPurchaseDate().toLocaleString() : "N/A", font)); pdfTable.addCell(new Paragraph("" + e.getAge(), font)); } } break; } case 11: // vehicle fuelings { numberOfColumns = 5; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Date", font)); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Litres", font)); pdfTable.addCell(new Paragraph("Amount", font)); pdfTable.addCell(new Paragraph("Source", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getFuelings() != null) { for (VehicleFueling e : getFuelings()) { pdfTable.addCell(new Paragraph(e.getCaptured_dt().toLocaleString(), font)); pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font)); pdfTable.addCell(new Paragraph("" + e.getLitres(), font)); pdfTable.addCell(new Paragraph("" + e.getAmt(), font)); pdfTable.addCell(new Paragraph(e.getSource(), font)); } } break; } case 12: // due vehicle licenses { numberOfColumns = 5; pdfTable = new PdfPTable(numberOfColumns); BaseFont helvetica = null; try { helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED); } catch (Exception e) { } Font font = new Font(helvetica, 8, Font.BOLDITALIC); pdfTable.addCell(new Paragraph("Reg No.", font)); pdfTable.addCell(new Paragraph("Fleet", font)); pdfTable.addCell(new Paragraph("Make", font)); pdfTable.addCell(new Paragraph("Model", font)); pdfTable.addCell(new Paragraph("License Due Date", font)); font = new Font(helvetica, 8, Font.NORMAL); if (getDueVehicleLicenses() != null) { for (VehicleLicense e : getDueVehicleLicenses()) { pdfTable.addCell(new Paragraph(e.getVehicle().getRegistrationNo(), font)); pdfTable.addCell(new Paragraph(e.getVehicle().getFleet().getName(), font)); pdfTable.addCell(new Paragraph( e.getVehicle().getModel() != null ? e.getVehicle().getModel().getMaker().getName() : "N/A", font)); pdfTable.addCell(new Paragraph( e.getVehicle().getModel() != null ? e.getVehicle().getModel().getName() : "N/A", font)); pdfTable.addCell(new Paragraph(e.getLic_end_dt().toLocaleString(), font)); } } break; } } pdfTable.setWidthPercentage(100); return pdfTable; }