List of usage examples for com.lowagie.text.pdf PdfPTable writeSelectedRows
public float writeSelectedRows(int rowStart, int rowEnd, float xPos, float yPos, PdfContentByte canvas)
From source file:se.idega.idegaweb.commune.school.business.StudentAddressLabelsWriter.java
License:Open Source License
/** * Adds a student address to the specified document. *//*from w ww . java2s .co m*/ protected void addAddress(PdfWriter writer, IWResourceBundle iwrb, MailReceiver student, int studentCount) { // User student = member.getStudent(); // Address address = userBusiness.getUsersMainAddress(student); // PostalCode postalCode = address != null ? address.getPostalCode() : null; // String name = student.getFirstName() + " " + student.getLastName(); // String streetAddress = address != null ? address.getStreetAddress() : ""; // String postalAddress = ""; // if (address != null && postalCode != null) { // String zip = postalCode.getPostalCode(); // if (zip.length() > 4) { // zip = zip.substring(0, 3) + " " + zip.substring(3, 5); // } // postalAddress = zip + " " + postalCode.getName(); // } PdfPTable table = new PdfPTable(1); table.setTotalWidth(ADDRESS_TABLE_WIDTH); table.getDefaultCell().setPadding(3); PdfPCell cell; cell = new PdfPCell( new Phrase(iwrb.getLocalizedString(KEY_TO_CUSTODIAN_FOR, "To custodian for") + ":", this.font)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(student.getStudentName(), this.font)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(student.getStreetAddress(), this.font)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(student.getPostalAddress(), this.font)); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); int row = (studentCount / NR_OF_COLUMNS) % NR_OF_ROWS; int column = studentCount % NR_OF_COLUMNS; table.writeSelectedRows(0, -1, LEFT_MARGIN + column * ADDRESS_TABLE_WIDTH, TOP_START - row * ADDRESS_TABLE_HEIGHT, writer.getDirectContent()); }