Java Code Examples for com.lowagie.text.Cell#setLeading()
The following examples show how to use
com.lowagie.text.Cell#setLeading() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElementFactory.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Creates a Cell object based on a list of properties. * * @param attributes * @return a Cell */ public static Cell getCell(Properties attributes) { Cell cell = new Cell(); String value; cell.setHorizontalAlignment(attributes.getProperty(ElementTags.HORIZONTALALIGN)); cell.setVerticalAlignment(attributes.getProperty(ElementTags.VERTICALALIGN)); value = attributes.getProperty(ElementTags.WIDTH); if (value != null) { cell.setWidth(value); } value = attributes.getProperty(ElementTags.COLSPAN); if (value != null) { cell.setColspan(Integer.parseInt(value)); } value = attributes.getProperty(ElementTags.ROWSPAN); if (value != null) { cell.setRowspan(Integer.parseInt(value)); } value = attributes.getProperty(ElementTags.LEADING); if (value != null) { cell.setLeading(Float.parseFloat(value + "f")); } cell.setHeader(Utilities.checkTrueOrFalse(attributes, ElementTags.HEADER)); if (Utilities.checkTrueOrFalse(attributes, ElementTags.NOWRAP)) { cell.setMaxLines(1); } setRectangleProperties(cell, attributes); return cell; }
Example 2
Source File: ElementFactory.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
/** * Creates a Cell object based on a list of properties. * @param attributes * @return a Cell */ public static Cell getCell(Properties attributes) { Cell cell = new Cell(); String value; cell.setHorizontalAlignment(attributes .getProperty(ElementTags.HORIZONTALALIGN)); cell.setVerticalAlignment(attributes .getProperty(ElementTags.VERTICALALIGN)); value = attributes.getProperty(ElementTags.WIDTH); if (value != null) { cell.setWidth(value); } value = attributes.getProperty(ElementTags.COLSPAN); if (value != null) { cell.setColspan(Integer.parseInt(value)); } value = attributes.getProperty(ElementTags.ROWSPAN); if (value != null) { cell.setRowspan(Integer.parseInt(value)); } value = attributes.getProperty(ElementTags.LEADING); if (value != null) { cell.setLeading(Float.parseFloat(value + "f")); } cell.setHeader(Utilities.checkTrueOrFalse(attributes, ElementTags.HEADER)); if (Utilities.checkTrueOrFalse(attributes, ElementTags.NOWRAP)) { cell.setMaxLines(1); } setRectangleProperties(cell, attributes); return cell; }
Example 3
Source File: RepeatingTableTest.java From itext2 with GNU Lesser General Public License v3.0 | 4 votes |
/** * Shows how a table is split if it doesn't fit the page. */ @Test public void main() throws Exception { // creation of the document with a certain size and certain margins Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50); // creation of the different writers PdfWriter.getInstance(document, PdfTestBase.getOutputStream("repeatingtable.pdf")); // we add some meta information to the document document.addAuthor("Alan Soukup"); document.addSubject("This is the result of a Test."); document.open(); Table datatable = new Table(10); int headerwidths[] = { 10, 24, 12, 12, 7, 7, 7, 7, 7, 7 }; datatable.setWidths(headerwidths); datatable.setWidth(100); datatable.setPadding(3); // the first cell spans 10 columns Cell cell = new Cell(new Phrase("Administration -System Users Report", FontFactory.getFont( FontFactory.HELVETICA, 24, Font.BOLD))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setLeading(30); cell.setColspan(10); cell.setBorder(Rectangle.NO_BORDER); cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0)); datatable.addCell(cell); // These cells span 2 rows datatable.getDefaultCell().setBorderWidth(2); datatable.getDefaultCell().setHorizontalAlignment(1); datatable.addCell("User Id"); datatable.addCell("Name\nAddress"); datatable.addCell("Company"); datatable.addCell("Department"); datatable.addCell("Admin"); datatable.addCell("Data"); datatable.addCell("Expl"); datatable.addCell("Prod"); datatable.addCell("Proj"); datatable.addCell("Online"); // this is the end of the table header datatable.endHeaders(); datatable.getDefaultCell().setBorderWidth(1); for (int i = 1; i < 30; i++) { datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); datatable.addCell("myUserId"); datatable .addCell("Somebody with a very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very, very long long name"); datatable.addCell("No Name Company"); datatable.addCell("D" + i); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell("No"); datatable.addCell("Yes"); datatable.addCell("No"); datatable.addCell("Yes"); datatable.addCell("No"); datatable.addCell("Yes"); } document.add(new Paragraph("com.lowagie.text.Table - Cells split")); document.add(datatable); document.newPage(); document.add(new Paragraph("com.lowagie.text.pdf.PdfPTable - Cells split\n\n")); datatable.setConvert2pdfptable(true); document.add(datatable); document.newPage(); document.add(new Paragraph("com.lowagie.text.Table - Cells kept together")); datatable.setConvert2pdfptable(false); datatable.setCellsFitPage(true); document.add(datatable); document.newPage(); document.add(new Paragraph("com.lowagie.text.pdf.PdfPTable - Cells kept together\n\n")); datatable.setConvert2pdfptable(true); document.add(datatable); // we close the document document.close(); }