List of usage examples for com.lowagie.text.pdf PdfPCell setBorder
public void setBorder(int border)
From source file:gov.medicaid.services.impl.ExportServiceBean.java
License:Apache License
/** * Adds a centered cell to the given table. * //from w w w.j a v a2s.c o m * @param table * the table to add the cell to * @param value * the value text */ private static void addCenterCell(PdfPTable table, String value) { PdfPCell val = new PdfPCell( new Phrase(Util.defaultString(value), FontFactory.getFont(FontFactory.HELVETICA, 7))); val.setBorder(Rectangle.NO_BORDER); val.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); table.addCell(val); }
From source file:gov.medicaid.services.impl.ExportServiceBean.java
License:Apache License
/** * Creates a header cell./* w w w.java 2 s . c o m*/ * * @param text * the header text * @param colspan * the span of the header * @return the generated cell. */ private static PdfPCell createHeaderCell(String text, int colspan) { PdfPCell header = new PdfPCell(new Phrase(text, FontFactory.getFont(FontFactory.HELVETICA_BOLD))); header.setBorder(Rectangle.BOTTOM); header.setColspan(colspan); return header; }
From source file:gov.medicaid.services.util.PDFHelper.java
License:Apache License
/** * Creates a header cell.//from ww w. ja v a2 s. c o m * * @param text the header text * @param colspan the span of the header * @return the generated cell. */ public static PdfPCell createHeaderCell(String text, int colspan) { PdfPCell header = new PdfPCell(new Phrase(text, FontFactory.getFont(FontFactory.HELVETICA_BOLD))); header.setBorder(Rectangle.BOTTOM); header.setColspan(colspan); return header; }
From source file:gov.medicaid.services.util.PDFHelper.java
License:Apache License
/** * Adds a label to the given table.// ww w . ja va 2 s . c o m * * @param table the table to add to * @param label the label text */ public static void addLabel(PdfPTable table, String label) { PdfPCell key = new PdfPCell( new Phrase(Util.defaultString(label), FontFactory.getFont(FontFactory.HELVETICA_BOLD, 8))); key.setBorder(Rectangle.NO_BORDER); table.addCell(key); }
From source file:gov.medicaid.services.util.PDFHelper.java
License:Apache License
/** * Adds a cell to the given table.//from w ww. java2 s . c om * * @param table the table to add the cell to * @param value the value text */ public static void addCell(PdfPTable table, String value) { PdfPCell val = new PdfPCell( new Phrase(": " + Util.defaultString(value), FontFactory.getFont(FontFactory.HELVETICA, 7))); val.setBorder(Rectangle.NO_BORDER); val.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); table.addCell(val); }
From source file:gov.medicaid.services.util.PDFHelper.java
License:Apache License
/** * Adds a centered cell to the given table. * * @param table the table to add the cell to * @param value the value text//from w ww.ja va 2 s . c o m */ public static void addCenterCell(PdfPTable table, String value) { PdfPCell val = new PdfPCell( new Phrase(Util.defaultString(value), FontFactory.getFont(FontFactory.HELVETICA, 7))); val.setBorder(Rectangle.NO_BORDER); val.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); val.setVerticalAlignment(PdfPCell.ALIGN_CENTER); table.addCell(val); }
From source file:ilarkesto.integration.itext.Paragraph.java
License:Open Source License
@Override public Element getITextElement() { com.lowagie.text.Paragraph p = new com.lowagie.text.Paragraph(); float maxSize = 0; for (AParagraphElement element : getElements()) { if (element instanceof TextChunk) { TextChunk textChunk = (TextChunk) element; FontStyle fontStyle = textChunk.getFontStyle(); FontSelector fontSelector = createFontSelector(fontStyle.getFont(), fontStyle); String text = textChunk.getText(); Phrase phrase = fontSelector.process(text); p.add(phrase);/*from w w w . j ava 2 s . c o m*/ float size = (fontStyle.getSize() * 1.1f) + 1f; if (size > maxSize) maxSize = PdfBuilder.mmToPoints(size); } else if (element instanceof Image) { Image image = (Image) element; com.lowagie.text.Image itextImage; try { itextImage = image.getITextElement(); } catch (Exception ex) { log.warn("Including image failed:", image, ex); continue; } if (image.getAlign() != null) { itextImage.setAlignment(Image.convertAlign(image.getAlign()) | com.lowagie.text.Image.TEXTWRAP); p.add(itextImage); } else { Chunk chunk = new Chunk(itextImage, 0, 0); p.add(chunk); float size = image.getHeight() + 3; if (size > maxSize) maxSize = size; } } else { throw new RuntimeException("Unsupported paragraph element: " + element.getClass().getName()); } } p.setLeading(maxSize); p.setSpacingBefore(PdfBuilder.mmToPoints(spacingTop)); p.setSpacingAfter(PdfBuilder.mmToPoints(spacingBottom)); if (align != null) p.setAlignment(convertAlign(align)); if (height <= 0) return p; // wrap in table PdfPCell cell = new PdfPCell(); cell.setBorder(0); cell.setFixedHeight(PdfBuilder.mmToPoints(height)); cell.addElement(p); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100); table.addCell(cell); return table; }
From source file:jdbreport.model.io.pdf.itext2.PdfWriter.java
License:Apache License
private void fillTable(ReportModel model, int leftCol, int topRow, int rightCol, int bottomRow, PdfPTable table) throws BadElementException, IOException, SaveReportException { TableRowModel rowModel = model.getRowModel(); for (int row = topRow; row < bottomRow; row++) { TableRow reportRow = rowModel.getRow(row); //Inserts first cell for calculate row height PdfPCell firstCell = new PdfPCell(); firstCell.setBorder(0); table.addCell(firstCell);//from w ww .jav a 2 s . co m for (int col = leftCol; col < rightCol; col++) { jdbreport.model.Cell srcCell = reportRow.getCellItem(col); if (!srcCell.isChild()) { PdfPCell pdfCell = writeCell(model, srcCell, row, col); table.addCell(pdfCell); } } } }
From source file:jm.web.Addons.java
License:GNU General Public License
public static PdfPCell setCeldaPDFBottom(String texto, int tipo, int tamanio, int estilo, int alineacion, int borde, int padding, int colspan) { PdfPCell celda = new PdfPCell(new Paragraph(texto, new Font(tipo, tamanio, estilo, Color.WHITE))); celda.setHorizontalAlignment(alineacion); celda.setVerticalAlignment(Element.ALIGN_TOP); celda.setBorderColor(Color.WHITE); celda.setColspan(colspan);//from w w w. java 2 s .c om celda.setBorder(borde); celda.setPadding(padding); return celda; }
From source file:lt.bsprendimai.ddesk.pdf.PDFTicket.java
License:Apache License
private void writeWorkerInfo(Document doc) throws Exception { PdfPTable tb = new PdfPTable(2); tb.setWidthPercentage(100.0f);//from w w w . j a v a2s. c om tb.setSpacingBefore(8.0f); tb.setSpacingAfter(8.0f); PdfPCell cl; cl = new PdfPCell(new Phrase("Atsakingas asmuo: " + me.getName(), new Font(baseArial, 10))); cl.setColspan(2); tb.addCell(cl); cl = new PdfPCell(new Phrase("vykdymo data: " + timeFormat(tt.getDateClosed()), new Font(baseArial, 10))); tb.addCell(cl); if (tt.getWorktime() != null) { cl = new PdfPCell(new Phrase("Darbo valandos:" + tt.getWorktime(), new Font(baseArial, 10))); tb.addCell(cl); } else { cl = new PdfPCell(new Phrase("Darbo valandos: ", new Font(baseArial, 10))); tb.addCell(cl); } doc.add(tb); tb = new PdfPTable(2); tb.setWidthPercentage(100.0f); tb.setSpacingBefore(50.0f); cl = new PdfPCell(new Phrase("Kliento paraas\n\n\n\n", new Font(baseArial, 10))); cl.setBorder(0); tb.addCell(cl); cl = new PdfPCell(new Phrase("Uduot atliks darbuotojas\n\n\n\n", new Font(baseArial, 10))); cl.setBorder(0); tb.addCell(cl); doc.add(tb); }