private void createTable() throws DocumentException { Phrase title = new Phrase(); title.setFont(new Font(FontFamily.HELVETICA, 13F, Font.BOLD, BaseColor.BLUE)); title.add("Violations"); document.add(new Paragraph(title)); document.add(new Paragraph(" ")); PdfPTable pdfTable = new PdfPTable(report.getLocaleColumnHeaders().length); pdfTable.setWidths(new int[] {3, 4, 1, 2, 2, 1}); pdfTable.setWidthPercentage(100); for (String columnHeader : report.getLocaleColumnHeaders()) { addCellToTable(pdfTable, columnHeader, BaseColor.GRAY, true); } for (Violation violation : report.getViolations().getValue()) { // Source if (violation.getClassPathFrom() != null && !violation.getClassPathFrom().trim().equals("")) { addCellToTable(pdfTable, violation.getClassPathFrom(), BaseColor.WHITE, false); } else { addCellToTable(pdfTable, "", BaseColor.WHITE, false); } // Rule if (violation.getMessage() != null) { String message = new Messagebuilder().createMessage(violation.getMessage(), violation); addCellToTable(pdfTable, message, BaseColor.WHITE, false); } else { addCellToTable(pdfTable, "", BaseColor.WHITE, false); } // LineNumber if (!(violation.getLinenumber() == 0)) { addCellToTable(pdfTable, "" + violation.getLinenumber(), BaseColor.WHITE, false); } else { addCellToTable(pdfTable, "", BaseColor.WHITE, false); } // DependencyKind if (violation.getViolationTypeKey() != null) { addCellToTable( pdfTable, getDependencyKindValue(violation.getViolationTypeKey(), violation.isIndirect()), BaseColor.WHITE, false); } else { addCellToTable(pdfTable, "", BaseColor.WHITE, false); } // Target if (violation.getClassPathFrom() != null && !violation.getClassPathFrom().trim().equals("")) { addCellToTable(pdfTable, violation.getClassPathTo(), BaseColor.WHITE, false); } else { addCellToTable(pdfTable, "", BaseColor.WHITE, false); } // Severity if (violation.getSeverity() != null) { addCellToTable( pdfTable, "" + violation.getSeverity().getSeverityName(), BaseColor.WHITE, false); } else { addCellToTable(pdfTable, "", BaseColor.WHITE, false); } } document.add(pdfTable); }