List of usage examples for com.itextpdf.text.pdf PdfPCell setBorder
public void setBorder(final int border)
From source file:facturacion.pdf.FacturaPdf.java
private PdfPCell getCellBorderTop(String text) throws DocumentException, IOException { Chunk chunk = new Chunk(); chunk.append(text);// w w w . j a v a2 s . c o m chunk.setFont(fontNormal); PdfPCell cell = new PdfPCell(new Paragraph(chunk)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(Rectangle.TOP); return cell; }
From source file:facturacion.pdf.FacturaPdf.java
private PdfPCell getCellNoBorder(String text) throws DocumentException, IOException { Chunk chunk = new Chunk(); chunk.append(text);// ww w . ja v a 2s .c om chunk.setFont(fontNormal); PdfPCell cell = new PdfPCell(new Paragraph(chunk)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(Rectangle.NO_BORDER); return cell; }
From source file:facturacion.pdf.FacturaPdf.java
private PdfPCell getCell(String text) throws DocumentException, IOException { Chunk chunk = new Chunk(); chunk.append(text);//from ww w.ja v a2s. co m chunk.setFont(fontNormal); PdfPCell cell = new PdfPCell(new Paragraph(chunk)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(Rectangle.LEFT); return cell; }
From source file:facturacion.pdf.FacturaPdf.java
private PdfPCell getCellBox(String text) throws DocumentException, IOException { Chunk chunk = new Chunk(); chunk.append(text);// ww w. ja va 2s.c om chunk.setFont(fontNormal); PdfPCell cell = new PdfPCell(new Paragraph(chunk)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(Rectangle.BOX); return cell; }
From source file:femr.ui.controllers.PDFController.java
License:Open Source License
/** * Builds the page header - Title and Empty cell (for border) * * @return PdfPTable the itext table to add to the document *///from www . j a v a2s .co m public PdfPTable createHeaderTable() { PdfPTable table = new PdfPTable(2); table.setSpacingAfter(10); table.setWidthPercentage(100); Paragraph title = new Paragraph("Medical Record", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD)); PdfPCell cell = new PdfPCell(title); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); cell.setBorder(PdfPCell.NO_BORDER); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderWidthBottom(1); cell.setPaddingBottom(5); table.addCell(cell); //Paragraph encounterId = new Paragraph("Encounter ID: " + patientEncounter.getId(), new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL)); cell = new PdfPCell(table.getDefaultCell()); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); cell.setBorder(PdfPCell.NO_BORDER); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderWidthBottom(1); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); return table; }
From source file:femr.ui.controllers.PDFController.java
License:Open Source License
/** * Builds the Header Cell used for every section of the document * * @param title the title for the cell/*from w w w.j a v a2s . c o m*/ * @param colspan the number of columns in the table it will be added to * @return a formatted PdfPCell ready to insert into a PdfPTable */ private PdfPCell getDefaultHeaderCell(String title, int colspan) { PdfPCell cell = new PdfPCell(); Paragraph titleParagraph = new Paragraph(title, new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK)); cell.addElement(titleParagraph); cell.setBorder(PdfPCell.NO_BORDER); cell.setColspan(colspan); cell.setBorderColorBottom(BaseColor.DARK_GRAY); cell.setBorderWidthBottom(1); cell.setPaddingBottom(5); return cell; }
From source file:femr.ui.controllers.PDFController.java
License:Open Source License
/** * Builds a cell that lists all values for the given key present in the vital map, * one measurement per line/*from w w w . ja v a 2 s . c o m*/ * * @param titleString The title of the vital map cell * @param key The key to get the values in the vital map * @param vitalMap the vital map that has all the values * @return PdfPCell the table cell formatted with the requested vital elements */ private PdfPCell getVitalMapCell(String titleString, String key, VitalMultiMap vitalMap) { PdfPCell cell = new PdfPCell(); cell.setBorder(PdfPCell.NO_BORDER); // Add the title Paragraph title = new Paragraph(titleString, getTitleFont()); cell.addElement(title); // For each vital value in the map add a new Paragraph element for (int dateIndex = 1; dateIndex <= vitalMap.getDateListChronological().size(); dateIndex++) { String value; if (key.equals("bloodPressure")) { value = outputStringOrNA(vitalMap.get("bloodPressureSystolic", vitalMap.getDate(dateIndex - 1))); value += '/' + outputStringOrNA(vitalMap.get("bloodPressureDiastolic", vitalMap.getDate(dateIndex - 1))); } else { value = outputStringOrNA(vitalMap.get(key, vitalMap.getDate(dateIndex - 1))); } Paragraph p = new Paragraph(value); cell.addElement(p); } return cell; }
From source file:file.PDFWriter.java
License:Open Source License
/** * Adds the table of possible errors to the PDF * @param errorIX the specific error to be bolded * @throws DocumentException /* w ww .j a va2s. c o m*/ */ private void addErrorTableToPDF(int errorIX) throws DocumentException { PdfPTable errorTable = new PdfPTable(7); errorTable.setWidthPercentage(100); for (int i = 0; i < errorOutput.length; i++) { errorFont.setStyle(Font.ITALIC); PdfPCell cell; if (i == errorIX) { cell = new PdfPCell(new Paragraph(errorOutput[i], errorFontBold)); } else { cell = new PdfPCell(new Paragraph(errorOutput[i], errorFont)); } cell.setBorder(PdfPCell.NO_BORDER); errorTable.addCell(cell); } document.add(errorTable); }
From source file:file.PDFWriter.java
License:Open Source License
/** * Add the page number and line to the PDF * @param splitLines the array of line segments to print * @param page the page number the line was on * @throws DocumentException /*from w ww. j a v a 2 s. c om*/ */ private void addLineTableToPDF(String[] splitLines, String page) throws DocumentException { PdfPTable lineTable = new PdfPTable(2); PdfPCell pageCell = new PdfPCell(new Paragraph("Page: " + page, lineFont)); pageCell.setPadding(20); pageCell.setPaddingLeft(0); pageCell.setBorder(PdfPCell.NO_BORDER); Chunk lineSegment1 = new Chunk(splitLines[0]); lineSegment1.setFont(lineFont); Chunk error1 = new Chunk(splitLines[1]); error1.setFont(lineFontBold); Chunk lineSegment2 = new Chunk(splitLines[2]); lineSegment2.setFont(lineFont); Chunk error2 = new Chunk(splitLines[3]); error2.setFont(lineFontBold); Chunk lineSegment3 = new Chunk(splitLines[4]); lineSegment3.setFont(lineFont); Phrase line = new Phrase(lineSegment1); line.add(error1); line.add(lineSegment2); line.add(error2); line.add(lineSegment3); PdfPCell lineCell = new PdfPCell(line); lineCell.setPadding(20); lineCell.setBorder(PdfPCell.NO_BORDER); lineTable.setWidthPercentage(100); lineTable.setWidths(new int[] { 2, 10 }); lineTable.setSpacingBefore(1f); lineTable.setSpacingAfter(1f); lineTable.addCell(pageCell); lineTable.addCell(lineCell); document.add(lineTable); document.add(Chunk.NEWLINE); }
From source file:file.PDFWriter.java
License:Open Source License
/** * Make the initial header to the PDF, with the date and character * @throws DocumentException/* w ww .ja v a2 s . c o m*/ */ public void makePDFHeader() throws DocumentException { PdfPTable headerTable = new PdfPTable(2); headerTable.setWidthPercentage(100); PdfPCell dateCell = new PdfPCell(new Paragraph( "Date: " + date.monthOfYear().getAsString() + "/" + date.dayOfMonth().getAsString(), lineFont)); dateCell.setHorizontalAlignment(Element.ALIGN_LEFT); dateCell.setBorder(PdfPCell.NO_BORDER); dateCell.setPadding(0.3f); PdfPCell characterCell = new PdfPCell(new Paragraph("Character: " + role.getName(), lineFont)); characterCell.setHorizontalAlignment(Element.ALIGN_RIGHT); characterCell.setBorder(PdfPCell.NO_BORDER); headerTable.addCell(dateCell); headerTable.addCell(characterCell); document.add(headerTable); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); }