List of usage examples for com.lowagie.text Paragraph Paragraph
public Paragraph(float leading, String string)
Paragraph
with a certain String
and a certain leading. From source file:be.fedict.eid.tsl.Tsl2PdfExporter.java
License:Open Source License
protected void addLongItem(final String label, final String value, final Document doc) throws DocumentException { doc.add(new Paragraph(label, labelFont)); doc.add(new Paragraph(value, valueFont)); }
From source file:be.fedict.eid.tsl.Tsl2PdfExporter.java
License:Open Source License
protected void addLongMonoItem(final String label, final String value, final Document doc) throws DocumentException { doc.add(new Paragraph(label, labelFont)); doc.add(new Paragraph(value, monoFont)); }
From source file:be.fedict.eid.tsl.Tsl2PdfExporter.java
License:Open Source License
protected void addTitle(final String titleText, final Font titleFont, final int align, final float spacingBefore, final float spacingAfter, final Document doc) throws DocumentException { final Paragraph titlePara = new Paragraph(titleText, titleFont); titlePara.setAlignment(align);//from w w w .ja v a 2s. co m titlePara.setSpacingBefore(spacingBefore); titlePara.setSpacingAfter(spacingAfter); doc.add(titlePara); }
From source file:binky.reportrunner.engine.renderers.exporters.HTMLExporter.java
License:Open Source License
@Override public void export(ResultSet resultSet, String label, OutputStream outputStream) throws ExportException { try {//from w w w . ja v a 2 s .com Document document = new Document(); HtmlWriter.getInstance(document, outputStream); // open the document object document.open(); ResultSetMetaData metaData = resultSet.getMetaData(); Table table = new Table(metaData.getColumnCount()); for (int i = 1; i <= metaData.getColumnCount(); i++) { Paragraph para = new Paragraph(metaData.getColumnName(i), new Font(Font.HELVETICA, 10, Font.BOLD)); Cell cell = new Cell(para); table.addCell(cell); } while (resultSet.next()) { for (int i = 1; i <= metaData.getColumnCount(); i++) { Paragraph para = new Paragraph("" + resultSet.getObject(i), new Font(Font.HELVETICA, 10, Font.NORMAL)); Cell cell = new Cell(para); table.addCell(cell); } } document.add(table); document.close(); } catch (DocumentException e) { throw new ExportException(e.getMessage(), e); } catch (SQLException e) { throw new ExportException(e.getMessage(), e); } }
From source file:binky.reportrunner.engine.renderers.exporters.PDFExporter.java
License:Open Source License
@Override public void export(ResultSet resultSet, String label, OutputStream outputStream) throws ExportException { try {//from w w w .j a va2s . co m Document document = new Document(); PdfWriter.getInstance(document, outputStream); // open the document object document.open(); ResultSetMetaData metaData = resultSet.getMetaData(); PdfPTable table = new PdfPTable(metaData.getColumnCount()); for (int i = 1; i <= metaData.getColumnCount(); i++) { Paragraph para = new Paragraph(metaData.getColumnName(i), new Font(Font.HELVETICA, 10, Font.BOLD)); PdfPCell cell = new PdfPCell(para); table.addCell(cell); } while (resultSet.next()) { for (int i = 1; i <= metaData.getColumnCount(); i++) { Paragraph para = new Paragraph("" + resultSet.getObject(i), new Font(Font.HELVETICA, 10, Font.NORMAL)); PdfPCell cell = new PdfPCell(para); table.addCell(cell); } } document.add(table); document.close(); } catch (DocumentException e) { throw new ExportException(e.getMessage(), e); } catch (SQLException e) { throw new ExportException(e.getMessage(), e); } }
From source file:br.com.nfsconsultoria.azcontrole.bean.VendaBean.java
public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException { Document pdf = (Document) document; pdf.setPageSize(PageSize.A4);//from w ww .j av a 2 s . co m pdf.addAuthor("Luis Carlos Santos"); pdf.addTitle("Acordo Cadastrados"); pdf.addCreator("NFS Consultoria"); pdf.addSubject("Acordo Cadastrados"); pdf.open(); Font catFont = new Font(Font.TIMES_ROMAN, 18, Font.BOLD); Paragraph p = new Paragraph("Relatrio de Acordos", catFont); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(20); ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); String logo = externalContext.getRealPath("") + File.separator + "resources" + File.separator + "images" + File.separator + "banner.png"; pdf.add(Image.getInstance(logo)); pdf.add(p); }
From source file:br.gov.jfrj.itextpdf.Documento.java
License:Open Source License
public static byte[] stamp(byte[] abPdf, String sigla, boolean rascunho, boolean cancelado, boolean semEfeito, boolean internoProduzido, String qrCode, String mensagem, Integer paginaInicial, Integer paginaFinal, Integer cOmitirNumeracao, String instancia, String orgaoUsu) throws DocumentException, IOException { PdfReader pdfIn = new PdfReader(abPdf); Document doc = new Document(PageSize.A4, 0, 0, 0, 0); // final SimpleDateFormat sdf = new SimpleDateFormat( // "EEE MMM dd HH:mm:ss zzz yyyy"); // doc.add(new Meta("creationdate", sdf.format(new Date(0L)))); final ByteArrayOutputStream boA4 = new ByteArrayOutputStream(); PdfWriter writer = PdfWriter.getInstance(doc, boA4); doc.open();// w ww . ja v a 2 s .c o m PdfContentByte cb = writer.getDirectContent(); // Resize every page to A4 size // // double thetaRotation = 0.0; for (int i = 1; i <= pdfIn.getNumberOfPages(); i++) { int rot = pdfIn.getPageRotation(i); float left = pdfIn.getPageSize(i).getLeft(); float bottom = pdfIn.getPageSize(i).getBottom(); float top = pdfIn.getPageSize(i).getTop(); float right = pdfIn.getPageSize(i).getRight(); PdfImportedPage page = writer.getImportedPage(pdfIn, i); float w = page.getWidth(); float h = page.getHeight(); // Logger.getRootLogger().error("----- dimensoes: " + rot + ", " + w // + ", " + h); doc.setPageSize((rot != 0 && rot != 180) ^ (w > h) ? PageSize.A4.rotate() : PageSize.A4); doc.newPage(); cb.saveState(); if (rot != 0 && rot != 180) { float swap = w; w = h; h = swap; } float pw = doc.getPageSize().getWidth(); float ph = doc.getPageSize().getHeight(); double scale = Math.min(pw / w, ph / h); // do my transformations : cb.transform(AffineTransform.getScaleInstance(scale, scale)); if (!internoProduzido) { cb.transform(AffineTransform.getTranslateInstance(pw * SAFETY_MARGIN, ph * SAFETY_MARGIN)); cb.transform(AffineTransform.getScaleInstance(1.0f - 2 * SAFETY_MARGIN, 1.0f - 2 * SAFETY_MARGIN)); } if (rot != 0) { double theta = -rot * (Math.PI / 180); if (rot == 180) { cb.transform(AffineTransform.getRotateInstance(theta, w / 2, h / 2)); } else { cb.transform(AffineTransform.getRotateInstance(theta, h / 2, w / 2)); } if (rot == 90) { cb.transform(AffineTransform.getTranslateInstance((w - h) / 2, (w - h) / 2)); } else if (rot == 270) { cb.transform(AffineTransform.getTranslateInstance((h - w) / 2, (h - w) / 2)); } } // Logger.getRootLogger().error( // "----- dimensoes: " + rot + ", " + w + ", " + h); // Logger.getRootLogger().error("----- page: " + pw + ", " + ph); // cb.transform(AffineTransform.getTranslateInstance( // ((pw / scale) - w) / 2, ((ph / scale) - h) / 2)); // put the page cb.addTemplate(page, 0, 0); // draw a red rectangle at the page borders // // cb.saveState(); // cb.setColorStroke(Color.red); // cb.rectangle(pdfIn.getPageSize(i).getLeft(), pdfIn.getPageSize(i) // .getBottom(), pdfIn.getPageSize(i).getRight(), pdfIn // .getPageSize(i).getTop()); // cb.stroke(); // cb.restoreState(); cb.restoreState(); } doc.close(); abPdf = boA4.toByteArray(); final ByteArrayOutputStream bo2 = new ByteArrayOutputStream(); final PdfReader reader = new PdfReader(abPdf); final int n = reader.getNumberOfPages(); final PdfStamper stamp = new PdfStamper(reader, bo2); // adding content to each page int i = 0; PdfContentByte under; PdfContentByte over; final BaseFont helv = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false); // Image img = Image.getInstance("watermark.jpg"); final BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED); byte maskr[] = { (byte) 0xff }; Image mask = Image.getInstance(1, 1, 1, 1, maskr); mask.makeMask(); mask.setInverted(true); while (i < n) { i++; // watermark under the existing page under = stamp.getUnderContent(i); over = stamp.getOverContent(i); final Barcode39 code39 = new Barcode39(); // code39.setCode(doc.getCodigo()); code39.setCode(sigla.replace("-", "").replace("/", "").replace(".", "")); code39.setStartStopText(false); final Image image39 = code39.createImageWithBarcode(over, null, null); Rectangle r = stamp.getReader().getPageSizeWithRotation(i); image39.setInitialRotation((float) Math.PI / 2.0f); image39.setAbsolutePosition( r.getWidth() - image39.getHeight() + (STAMP_BORDER_IN_CM - PAGE_BORDER_IN_CM) * CM_UNIT, BARCODE_HEIGHT_IN_CM * CM_UNIT); image39.setBackgroundColor(Color.green); image39.setBorderColor(Color.RED); image39.setBorderWidth(0.5f * CM_UNIT); image39.setImageMask(mask); over.setRGBColorFill(255, 255, 255); mask.setAbsolutePosition(r.getWidth() - image39.getHeight() - (PAGE_BORDER_IN_CM) * CM_UNIT, (BARCODE_HEIGHT_IN_CM - STAMP_BORDER_IN_CM) * CM_UNIT); mask.scaleAbsolute(image39.getHeight() + 2 * STAMP_BORDER_IN_CM * CM_UNIT, image39.getWidth() + 2 * STAMP_BORDER_IN_CM * CM_UNIT); over.addImage(mask); over.setRGBColorFill(0, 0, 0); over.addImage(image39); // over.addImage(mask, mask.getScaledWidth() * 8, 0, 0, // mask.getScaledHeight() * 8, 100, 450); if (qrCode != null) { java.awt.Image imgQRCode = createQRCodeImage(qrCode); Image imageQRCode = Image.getInstance(imgQRCode, Color.BLACK, true); imageQRCode.scaleAbsolute(QRCODE_SIZE_IN_CM * CM_UNIT, QRCODE_SIZE_IN_CM * CM_UNIT); imageQRCode.setAbsolutePosition(QRCODE_LEFT_MARGIN_IN_CM * CM_UNIT, PAGE_BORDER_IN_CM * CM_UNIT); over.setRGBColorFill(255, 255, 255); mask.setAbsolutePosition((QRCODE_LEFT_MARGIN_IN_CM - STAMP_BORDER_IN_CM) * CM_UNIT, (PAGE_BORDER_IN_CM - STAMP_BORDER_IN_CM) * CM_UNIT); mask.scaleAbsolute((QRCODE_SIZE_IN_CM + 2 * STAMP_BORDER_IN_CM) * CM_UNIT, (QRCODE_SIZE_IN_CM + 2 * STAMP_BORDER_IN_CM) * CM_UNIT); over.addImage(mask); over.setRGBColorFill(0, 0, 0); over.addImage(imageQRCode); } if (mensagem != null) { PdfPTable table = new PdfPTable(1); table.setTotalWidth(r.getWidth() - image39.getHeight() - (QRCODE_LEFT_MARGIN_IN_CM + QRCODE_SIZE_IN_CM + 4 * STAMP_BORDER_IN_CM + PAGE_BORDER_IN_CM) * CM_UNIT); PdfPCell cell = new PdfPCell(new Paragraph(mensagem, FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, Color.BLACK))); cell.setBorderWidth(0); table.addCell(cell); over.setRGBColorFill(255, 255, 255); mask.setAbsolutePosition( (QRCODE_LEFT_MARGIN_IN_CM + QRCODE_SIZE_IN_CM + STAMP_BORDER_IN_CM) * CM_UNIT, (PAGE_BORDER_IN_CM - STAMP_BORDER_IN_CM) * CM_UNIT); mask.scaleAbsolute(2 * STAMP_BORDER_IN_CM * CM_UNIT + table.getTotalWidth(), 2 * STAMP_BORDER_IN_CM * CM_UNIT + table.getTotalHeight()); over.addImage(mask); over.setRGBColorFill(0, 0, 0); table.writeSelectedRows(0, -1, (QRCODE_LEFT_MARGIN_IN_CM + QRCODE_SIZE_IN_CM + 2 * STAMP_BORDER_IN_CM) * CM_UNIT, table.getTotalHeight() + PAGE_BORDER_IN_CM * CM_UNIT, over); } if (cancelado) { over.saveState(); final PdfGState gs = new PdfGState(); gs.setFillOpacity(0.5f); over.setGState(gs); over.setColorFill(Color.GRAY); over.beginText(); over.setFontAndSize(helv, 72); over.showTextAligned(Element.ALIGN_CENTER, "CANCELADO", r.getWidth() / 2, r.getHeight() / 2, 45); over.endText(); over.restoreState(); } else if (rascunho) { over.saveState(); final PdfGState gs = new PdfGState(); gs.setFillOpacity(0.5f); over.setGState(gs); over.setColorFill(Color.GRAY); over.beginText(); over.setFontAndSize(helv, 72); over.showTextAligned(Element.ALIGN_CENTER, "MINUTA", r.getWidth() / 2, r.getHeight() / 2, 45); over.endText(); over.restoreState(); } else if (semEfeito) { over.saveState(); final PdfGState gs = new PdfGState(); gs.setFillOpacity(0.5f); over.setGState(gs); over.setColorFill(Color.GRAY); over.beginText(); over.setFontAndSize(helv, 72); over.showTextAligned(Element.ALIGN_CENTER, "SEM EFEITO", r.getWidth() / 2, r.getHeight() / 2, 45); over.endText(); over.restoreState(); } // if (!rascunho // && request.getRequestURL().indexOf("http://laguna/") == -1) { if (!rascunho && !cancelado && !semEfeito && ((!Contexto.resource("isVersionTest").equals("false")) || (!Contexto.resource("isBaseTest").equals("false")))) { over.saveState(); final PdfGState gs = new PdfGState(); gs.setFillOpacity(0.5f); over.setGState(gs); over.setColorFill(Color.GRAY); over.beginText(); over.setFontAndSize(helv, 72); over.showTextAligned(Element.ALIGN_CENTER, "INVLIDO", r.getWidth() / 2, r.getHeight() / 2, 45); over.endText(); over.restoreState(); } // Imprime um circulo com o numero da pagina dentro. if (paginaInicial != null) { String sFl = String.valueOf(paginaInicial + i - 1); // Se for a ultima pagina e o numero nao casar, acrescenta "-" e // pagina final if (n == i) { if (paginaFinal != paginaInicial + n - 1) { sFl = sFl + "-" + String.valueOf(paginaFinal); } } if (i > cOmitirNumeracao) { // Raio do circulo interno final float radius = 18f; // Distancia entre o circulo interno e o externo final float circleInterspace = Math.max(helv.getAscentPoint(instancia, TEXT_HEIGHT), helv.getAscentPoint(orgaoUsu, TEXT_HEIGHT)) - Math.min(helv.getDescentPoint(instancia, TEXT_HEIGHT), helv.getDescentPoint(orgaoUsu, TEXT_HEIGHT)) + 2 * TEXT_TO_CIRCLE_INTERSPACE; // Centro do circulo float xCenter = r.getWidth() - 1.8f * (radius + circleInterspace); float yCenter = r.getHeight() - 1.8f * (radius + circleInterspace); over.saveState(); final PdfGState gs = new PdfGState(); gs.setFillOpacity(1f); over.setGState(gs); over.setColorFill(Color.BLACK); over.saveState(); over.setColorStroke(Color.black); over.setLineWidth(1f); over.setColorFill(Color.WHITE); // Circulo externo over.circle(xCenter, yCenter, radius + circleInterspace); over.fill(); over.circle(xCenter, yCenter, radius + circleInterspace); over.stroke(); // Circulo interno over.circle(xCenter, yCenter, radius); over.stroke(); over.restoreState(); { over.saveState(); over.beginText(); over.setFontAndSize(helv, TEXT_HEIGHT); // Escreve o texto superior do carimbo float fDescent = helv.getDescentPoint(instancia, TEXT_HEIGHT); showTextOnArc(over, instancia, helv, TEXT_HEIGHT, xCenter, yCenter, radius - fDescent + TEXT_TO_CIRCLE_INTERSPACE, true); // Escreve o texto inferior float fAscent = helv.getAscentPoint(orgaoUsu, TEXT_HEIGHT); showTextOnArc(over, orgaoUsu, helv, TEXT_HEIGHT, xCenter, yCenter, radius + fAscent + TEXT_TO_CIRCLE_INTERSPACE, false); over.endText(); over.restoreState(); } over.beginText(); int textHeight = 23; // Diminui o tamanho do font ate que o texto caiba dentro do // circulo interno while (helv.getWidthPoint(sFl, textHeight) > (2 * (radius - TEXT_TO_CIRCLE_INTERSPACE))) textHeight--; float fAscent = helv.getAscentPoint(sFl, textHeight) + helv.getDescentPoint(sFl, textHeight); over.setFontAndSize(helv, textHeight); over.showTextAligned(Element.ALIGN_CENTER, sFl, xCenter, yCenter - 0.5f * fAscent, 0); over.endText(); over.restoreState(); } } } stamp.close(); return bo2.toByteArray(); }
From source file:br.gov.jfrj.siga.ex.util.GeradorRTF.java
License:Open Source License
public byte[] geraRTF(ExDocumento doc) throws Exception { html = doc.getConteudoBlobHtmlString(); html = (new ProcessadorHtml()).canonicalizarHtml(html, true, false, true, true, false); html = html.replace("<!-- INICIO MIOLO -->", "<MIOLO>"); html = html.replace("<!-- FIM MIOLO -->", "</MIOLO>"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); RtfWriter2.getInstance(document, baos); document.open();/*from w w w. jav a2s . c o m*/ document.setMargins(29, 340, 29, 29); parser.setInput(new StringReader(html)); BaseFont arial = BaseFont.createFont("C:\\WINDOWS\\FONTS\\ARIAL.TTF", BaseFont.CP1252, true); Font fonte = new Font(arial); fonte.setSize(7); Paragraph paragrafoBase = new Paragraph("", fonte); paragrafoBase.add("\t" + doc.getOrgaoUsuario().getDescricaoMaiusculas()); paragrafoBase.add("\n\n"); paragrafoBase .add("\t" + doc.getExFormaDocumento().getDescricao().toUpperCase() + " " + doc.getCodigoString()); if (doc.getDtDocDDMMYY() != null && doc.getDtDocDDMMYY().length() > 0) paragrafoBase.add(" DE " + doc.getDtDocDDMMYY()); paragrafoBase.add("\n\n"); try { seekTag("MIOLO"); paragrafoBase = (Paragraph) percorreProximoBloco(paragrafoBase, 0, true); document.add(paragrafoBase); } catch (XmlPullParserException xppe) { int a = 2; } catch (IOException ioe) { int a = 2; } finally { document.close(); } /* * Pattern p1 = Pattern .compile("^.<!-- INICIO MIOLO -->.<!-- * FIM MIOLO -->."); final Matcher m = p1.matcher(html); */ byte[] retorno = baos.toByteArray(); baos.close(); return retorno; }
From source file:ca.nines.ise.writer.RTFWriter.java
License:Open Source License
private void startParagraph(RtfParagraphStyle style) throws DocumentException { if (!p.isEmpty() && !StringUtils.isWhitespace(p.getContent())) { doc.add(p);// ww w . j a v a 2s. c o m } p = new Paragraph("", style); }
From source file:ca.sqlpower.architect.profile.output.ProfilePDFFormat.java
License:Open Source License
private void addBodyRow(TableProfileResult tProfile, ColumnProfileResult result, DDLGenerator ddlg, PdfPTable table, BaseFont bf, Font f, float fsize, float[] widths) throws DocumentException, IOException, SQLObjectException, SQLException { SQLColumn col = result.getProfiledObject(); int rowCount = -1; if (tProfile != null && tProfile.getException() == null) { rowCount = tProfile.getRowCount(); }//from ww w. j a va 2 s . c om java.util.List<ColumnValueCount> topTen = null; boolean errorColumnProfiling = false; Exception columnException = null; if (result != null && result.getException() == null) { topTen = result.getValueCount(); } else { errorColumnProfiling = true; if (result != null && result.getException() != null) { columnException = result.getException(); logger.debug("Exception " + columnException + " on column " + col.getName()); } } DecimalFormat pctFormat = new DecimalFormat("0%"); DecimalFormat df = new DecimalFormat("#,##0.00"); df.setMaximumFractionDigits(col.getScale()); df.setMinimumFractionDigits(col.getScale()); DecimalFormat adf = new DecimalFormat("#,##0.00"); adf.setMaximumFractionDigits(Math.max(2, col.getScale())); adf.setMinimumFractionDigits(Math.max(2, col.getScale())); DecimalFormat aldf = new DecimalFormat("#,##0.0"); aldf.setMaximumFractionDigits(1); aldf.setMinimumFractionDigits(0); boolean errorSpanRemaining = false; for (int colNo = 0; colNo < totalColumn; colNo++) { String contents; int alignment; if (headings[colNo].equalsIgnoreCase("table name")) { String fqTableName = SQLObjectUtils.toQualifiedName(col.getParent(), SQLDatabase.class); if (tProfile == null || tProfile.getException() != null) { contents = fqTableName + "\nProfiling Error:\n"; if (tProfile != null && tProfile.getException() != null) { contents += tProfile.getException(); errorSpanRemaining = true; } } else { contents = fqTableName; } alignment = Element.ALIGN_LEFT; } else if (headings[colNo].equalsIgnoreCase("row count")) { contents = String.valueOf(rowCount); alignment = Element.ALIGN_RIGHT; } else if (headings[colNo].equalsIgnoreCase("column name")) { contents = col.getName(); alignment = Element.ALIGN_LEFT; } else if (headings[colNo].equalsIgnoreCase("data type")) { contents = ddlg.columnType(col); alignment = Element.ALIGN_LEFT; } else if (headings[colNo].equalsIgnoreCase("null count")) { if (errorColumnProfiling) { if (result == null) { contents = "Column Profiling Not Found\n"; } else { contents = "Column Profiling Error:\n"; if (columnException != null) { contents += columnException; errorSpanRemaining = true; } } alignment = Element.ALIGN_LEFT; } else { if (col.isDefinitelyNullable()) { contents = String.valueOf(result.getNullCount()); } else { contents = "---"; } alignment = Element.ALIGN_RIGHT; } } else if (headings[colNo].equalsIgnoreCase("% null")) { if (errorColumnProfiling) { continue; } else { if (col.isDefinitelyNullable()) { if (rowCount <= 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(result.getNullCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { contents = "---"; alignment = Element.ALIGN_CENTER; } } } else if (headings[colNo].equalsIgnoreCase("Unique Count")) { if (!errorColumnProfiling) { contents = String.valueOf(result.getDistinctValueCount()); alignment = Element.ALIGN_RIGHT; } else { continue; } } else if (headings[colNo].equalsIgnoreCase("% unique")) { if (!errorColumnProfiling) { if (rowCount == 0) { contents = "N/A"; alignment = Element.ALIGN_CENTER; } else { contents = pctFormat.format(result.getDistinctValueCount() / (double) rowCount); alignment = Element.ALIGN_RIGHT; } } else { continue; } } else if (headings[colNo].equalsIgnoreCase("Min Length")) { if (!errorColumnProfiling) { contents = String.valueOf(result.getMinLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (headings[colNo].equalsIgnoreCase("Max Length")) { if (!errorColumnProfiling) { contents = String.valueOf(result.getMaxLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (headings[colNo].equalsIgnoreCase("avg Length")) { if (!errorColumnProfiling) { contents = aldf.format(result.getAvgLength()); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (headings[colNo].equalsIgnoreCase("Min value")) { if (!errorColumnProfiling) { if (result.getMinValue() == null) { alignment = Element.ALIGN_CENTER; contents = ""; } else if (result.getMinValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; contents = df.format((Number) result.getMinValue()); } else { alignment = Element.ALIGN_LEFT; contents = String.valueOf(result.getMinValue()); } alignment = Element.ALIGN_LEFT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (headings[colNo].equalsIgnoreCase("Max value")) { if (!errorColumnProfiling) { if (result.getMaxValue() == null) { alignment = Element.ALIGN_CENTER; contents = ""; } else if (result.getMaxValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; contents = df.format((Number) result.getMaxValue()); } else { alignment = Element.ALIGN_LEFT; contents = String.valueOf(result.getMaxValue()); } alignment = Element.ALIGN_LEFT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (headings[colNo].equalsIgnoreCase("avg value")) { if (!errorColumnProfiling) { if (result.getAvgValue() == null) { alignment = Element.ALIGN_CENTER; contents = ""; } else if (result.getAvgValue() instanceof Number) { alignment = Element.ALIGN_RIGHT; contents = adf.format((Number) result.getAvgValue()); } else { alignment = Element.ALIGN_LEFT; contents = String.valueOf(result.getAvgValue()); } } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (headings[colNo].equalsIgnoreCase("Top N Values")) { if (!errorColumnProfiling && topTen != null) { StringBuffer sb = new StringBuffer(); for (ColumnValueCount cvc : topTen) { sb.append(cvc.getValue()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_LEFT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else if (headings[colNo].equalsIgnoreCase("Count")) { if (!errorColumnProfiling) { StringBuffer sb = new StringBuffer(); for (ColumnValueCount cvc : topTen) { sb.append(cvc.getCount()).append("\n"); } contents = sb.toString(); alignment = Element.ALIGN_RIGHT; } else { contents = ""; alignment = Element.ALIGN_LEFT; } } else { throw new IllegalStateException("I don't know about column " + colNo); } StringBuffer truncContents = new StringBuffer(contents.length()); // update column width to reflect the widest cell for (String contentLine : contents.split("\n")) { String newLine; if (truncateLength >= 0 && !errorSpanRemaining) { if (bf.getWidthPoint(contentLine, fsize) < truncateLength) { newLine = contentLine + "\n"; } else { double currentLength = bf.getWidthPoint("...", fsize); int stringPosition = 0; for (; stringPosition < contentLine.length(); stringPosition++) { if (currentLength > truncateLength) { break; } currentLength = bf.getWidthPoint(contentLine.substring(0, stringPosition) + "...", fsize); stringPosition++; } newLine = contentLine.substring(0, stringPosition - 1) + "...\n"; } } else { newLine = contentLine + "\n"; } truncContents.append(newLine); if (!errorSpanRemaining) { widths[colNo] = Math.max(widths[colNo], bf.getWidthPoint(newLine, fsize)); logger.debug("width is now " + widths[colNo] + " for column " + colNo); } } PdfPCell cell; if (headings[colNo].equalsIgnoreCase("Top N Values") || headings[colNo].equalsIgnoreCase("Count")) { cell = new PdfPCell(new Paragraph(truncContents.toString(), f)); cell.setNoWrap(true); } else if (headings[colNo].equalsIgnoreCase("null count") && errorColumnProfiling) { cell = new PdfPCell(new Paragraph(truncContents.toString(), f)); cell.setColspan(4); } else { Phrase phr = new Phrase(truncContents.toString(), f); cell = new PdfPCell(phr); } // cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(alignment); if (errorSpanRemaining) { cell.setColspan(totalColumn - colNo); } table.addCell(cell); if (errorSpanRemaining) { break; } } }