@Override protected final void addMovementCells( SheetGraphics graphics, PdfPTable table, HealthLevelType level, int painTolerance, IGenericTraitCollection collection) { int woundPenalty = getPenalty(level, painTolerance); int dex = collection.getTrait(AttributeType.Dexterity).getCurrentValue(); int str = collection.getTrait(AttributeType.Strength).getCurrentValue(); int athletics = collection.getTrait(AbilityType.Athletics).getCurrentValue(); // minimum move is 1, minimum dash is 2, minimum jump h/v, swim, & climb is unknown int move = Math.max(dex + woundPenalty + mobilityPenalty, 1); int dash = Math.max(dex + woundPenalty + mobilityPenalty + 6, 2); int verticalJump = str + athletics + woundPenalty + mobilityPenalty; int horizontalJump = verticalJump * 2; table.addCell(createMovementCell(graphics, move, 1)); addSpaceCells(graphics, table, 1); table.addCell(createMovementCell(graphics, dash, 2)); addSpaceCells(graphics, table, 1); table.addCell(createMovementCell(graphics, horizontalJump, 0)); table.addCell(createMovementCell(graphics, verticalJump, 0)); }
/** * Processes the Table. * * @throws DocumentException * @since 5.0.6 */ public void processTable() throws DocumentException { TableWrapper table = (TableWrapper) stack.pop(); PdfPTable tb = table.createTable(); tb.setSplitRows(true); if (stack.empty()) document.add(tb); else ((TextElementArray) stack.peek()).add(tb); }
private PdfPTable cuerpoSol(final List<VUSolicitud> listSol) throws DocumentException { final PdfPTable body = new PdfPTable(5); body.setWidthPercentage(95); final Map<String, Object> mapConfig = this.getMapSol(); // pinta los header de la tabla for (final String header : VUTramConstants.listHeRep) { body.addCell(this.constCelda(header, mapConfig)); } for (final VUSolicitud solicitud : listSol) { body.addCell(this.constCeldaR(solicitud.getFolio(), mapConfig)); body.addCell(this.constCeldaR(solicitud.getTramite().getDescDeptoTram(), mapConfig)); body.addCell(this.constCeldaR(solicitud.getTramite().getDescTram(), mapConfig)); body.addCell(this.constCeldaR(solicitud.getFecView(), mapConfig)); body.addCell(this.constCeldaR(solicitud.getEstSol().getDescEst(), mapConfig)); body.completeRow(); } PdfPCell celdaValor = new PdfPCell(new Phrase("")); celdaValor.setColspan(50); celdaValor.setBorder(0); body.addCell(celdaValor); return body; }
private PdfPTable footer() { PdfPTable footer = new PdfPTable(1); footer.setTotalWidth(523); Font colorLetra = new Font(); colorLetra.setColor(new BaseColor(Color.white)); colorLetra.setSize(8); PdfPCell cell = new PdfPCell( new Paragraph( messageSource.getMessage("generaPdf.pdf.DireccionPart1", null, Locale.getDefault()), colorLetra)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(0, 0, 0)); footer.addCell(cell); cell = new PdfPCell( new Paragraph( messageSource.getMessage("generaPdf.pdf.DireccionPart2", null, Locale.getDefault()), colorLetra)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(0, 0, 0)); footer.addCell(cell); cell = new PdfPCell( new Paragraph( messageSource.getMessage("generaPdf.pdf.DireccionPart3", null, Locale.getDefault()), colorLetra)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(0, 0, 0)); footer.addCell(cell); return footer; }
// --- GET GROWTH GRAPHS ----------------------------------------------------------------------- protected PdfPTable getGrowthGraphs() throws Exception { PdfPTable growthTable = new PdfPTable(1); growthTable.setWidthPercentage(pageWidth); // *** height graph **************************************************** ByteArrayOutputStream osHeight = new ByteArrayOutputStream(); ChartUtilities.writeChartAsPNG(osHeight, getHeightGraph(), 680, 350); // put image in cell cell = new PdfPCell(); cell.setImage(com.itextpdf.text.Image.getInstance(osHeight.toByteArray())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingRight(10); growthTable.addCell(cell); // spacer growthTable.addCell(createBorderlessCell("", 30, 1)); // *** weight graph **************************************************** ByteArrayOutputStream osWeight = new ByteArrayOutputStream(); ChartUtilities.writeChartAsPNG(osWeight, getWeightGraph(), 680, 350); // put image in cell cell = new PdfPCell(); cell.setImage(com.itextpdf.text.Image.getInstance(osWeight.toByteArray())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingRight(10); growthTable.addCell(cell); return growthTable; }
@Override public void addContent(PdfPTable table, Font font, IMagicStats stats) { if (stats == null) { table.addCell(createTextCell(font, "")); } else { table.addCell(createTextCell(font, stats.getNameString(resources))); } }
@Override public void addContent(PdfPTable table, Font font, IArmourStats stats) { if (stats == null) { table.addCell(createEmptyValueCell(font)); } else { table.addCell(createEquipmentValueCell(font, stats.getFatigue())); } }
protected void addAnimaRow( SheetGraphics graphics, PdfPTable table, int level, ReportSession session, String descriptionPrefix) { table.addCell(createRangeCell(graphics, level, session.getHero())); table.addCell(createDescriptionCell(graphics, level, descriptionPrefix)); table.addCell(createStealthCell(graphics, level)); }
private void addProductDetails(Document document) throws BadElementException, DocumentException { Paragraph preface = new Paragraph(); addEmptyLine(preface, 5); document.add(preface); PdfPTable table = new PdfPTable(3); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell c1 = new PdfPCell(new Phrase("Product ID")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); PdfPCell c2 = new PdfPCell(new Phrase("Current Stock")); c2.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c2); PdfPCell c3 = new PdfPCell(new Phrase("Minimum Stock")); c3.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c3); table.setHeaderRows(1); ArrayList<ArrayList<String>> products = rprtDBAccess.getLowStockedProducts(); for (int i = 0; i < products.size(); i++) { ArrayList<String> product = products.get(i); table.addCell(product.get(0)); // product id table.addCell(product.get(1)); // currentstock table.addCell(product.get(2)); // minimumstock table.completeRow(); } document.add(table); }
void add(String name, PdfPTable table1, int n) { PdfPCell c5 = new PdfPCell(new Phrase(name, new Font(FontFamily.TIMES_ROMAN, 14, Font.BOLD))); c5.setHorizontalAlignment(n); c5.setPaddingTop(25); c5.setFixedHeight(60f); table1.addCell(c5); PdfPCell c6 = new PdfPCell(new Phrase(" ", new Font(FontFamily.TIMES_ROMAN, 14, Font.BOLD))); table1.addCell(c6); PdfPCell c7 = new PdfPCell(new Phrase(" ", new Font(FontFamily.TIMES_ROMAN, 14, Font.BOLD))); table1.addCell(c7); }
public void generarPDFComprobante(Comprobante c) throws DocumentException, FileNotFoundException { Document documento = new Document(); FileOutputStream archivoPDF; Calendar cal; cal = Calendar.getInstance(); cal.setTime(c.getFecha()); SimpleDateFormat d = new SimpleDateFormat("dd-MM-yyyy"); String fecha = d.format(c.getFecha()); String nombre = "./impresiones/comprobantes/comp" + c.getClaseLicencia().getNombre() + "_" + fecha + ".PDF"; archivoPDF = new FileOutputStream(nombre); PdfWriter.getInstance(documento, archivoPDF).setInitialLeading(20); documento.open(); PdfPTable tabla = new PdfPTable(2); tabla.getDefaultCell().setBorder(Rectangle.NO_BORDER); PdfPCell celda1 = new PdfPCell( new Phrase( "Nombre: " + c.getTitular().getIdUsuario().getNombre() + " " + c.getTitular().getIdUsuario().getApellido())); celda1.setBorder(Rectangle.LEFT | Rectangle.TOP); PdfPCell celda2 = new PdfPCell(new Phrase("Clase: " + c.getClaseLicencia().getNombre())); celda2.setBorder(Rectangle.RIGHT | Rectangle.TOP); PdfPCell celda3 = new PdfPCell(new Phrase("Monto: $" + c.getMontoAbonado())); celda3.setBorder(Rectangle.LEFT | Rectangle.BOTTOM); PdfPCell celda4 = new PdfPCell(new Phrase("Fecha: " + fecha)); celda4.setBorder(Rectangle.RIGHT | Rectangle.BOTTOM); tabla.addCell(celda1); tabla.addCell(celda2); tabla.addCell(celda3); tabla.addCell(celda4); documento.add(tabla); documento.close(); }
private PdfPTable buildHeader(String date) throws BadElementException, IOException { PdfPCell cell; PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100); table.getDefaultCell().setBorder(0); Resource r = appContex.getResource("/img/logo_mairie.png"); Image img = Image.getInstance(r.getFile().getAbsolutePath()); cell = new PdfPCell(); cell.addElement(new Chunk(img, 60, 0)); cell.setFixedHeight(70); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setPaddingTop(23); cell.setBorder(Rectangle.NO_BORDER); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell(new Phrase("FICHE EVENEMENTIELLE", FONT_TITLE)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); Resource r2 = appContex.getResource("/img/logo_police_nc.jpg"); Image img2 = Image.getInstance(r2.getFile().getAbsolutePath()); cell = new PdfPCell(); cell.addElement(new Chunk(img2, 130, 0)); cell.setFixedHeight(70); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setPaddingTop(23); cell.setBorder(Rectangle.NO_BORDER); cell.setRowspan(2); table.addCell(cell); cell = new PdfPCell( new Phrase( "Fiche éditée le " + date + "\npar " + authHelper.getCurrentUser().getAgent().getNom() + " " + authHelper.getCurrentUser().getAgent().getPrenom(), FONT_TITLE_LIGHT)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); table.setSpacingBefore(5); table.setSpacingAfter(5); return table; }
private static void addQuittingTimes( PdfPTable table, String employmentTime, String employerWarning, String employeeWarning) { PdfPCell timeCell = new PdfPCell(); timeCell.addElement(PdfHelper.lastLineParagraph(employmentTime)); table.addCell(timeCell); PdfPCell employerCell = new PdfPCell(); employerCell.addElement(PdfHelper.lastLineParagraph(employerWarning)); table.addCell(employerCell); PdfPCell employeeCell = new PdfPCell(); employeeCell.addElement(PdfHelper.lastLineParagraph(employeeWarning)); table.addCell(employeeCell); }
private PdfPTable cuerpo(final List<String> listaHeaderTable, final Map<String, String> mapa) throws DocumentException { PdfPTable body = new PdfPTable(12); body.setWidthPercentage(100); Font colorLetra = null; Paragraph aliniarTexto = null; PdfPCell cellCuerpoHeader = null; // pinta los header de la tabla for (String valorCelda : listaHeaderTable) { aliniarTexto = new Paragraph(); aliniarTexto.setAlignment(Element.ALIGN_CENTER); colorLetra = new Font(); colorLetra.setColor(new BaseColor(Color.white)); cellCuerpoHeader = new PdfPCell(new Phrase(valorCelda, colorLetra)); cellCuerpoHeader.setHorizontalAlignment(Element.ALIGN_CENTER); cellCuerpoHeader.setBackgroundColor(new BaseColor(0, 0, 0)); cellCuerpoHeader.setBorder(Rectangle.NO_BORDER); cellCuerpoHeader.setColspan(12); body.addCell(cellCuerpoHeader); } PdfPCell cellSaltoDeLinea = new PdfPCell(); cellSaltoDeLinea = new PdfPCell(new Phrase(" ")); cellSaltoDeLinea.setBorder(Rectangle.NO_BORDER); cellSaltoDeLinea.setColspan(12); body.addCell(cellSaltoDeLinea); for (Map.Entry<String, String> entry : mapa.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); PdfPCell celdaEnBlanco = new PdfPCell(new Phrase("")); celdaEnBlanco.setColspan(2); celdaEnBlanco.setBorder(0); aliniarTexto = new Paragraph(); aliniarTexto.setAlignment(Element.ALIGN_CENTER); colorLetra = new Font(); colorLetra.setColor(new BaseColor(Color.BLACK)); PdfPCell celdaKey = new PdfPCell(new Phrase(key, colorLetra)); celdaKey.setColspan(3); celdaKey.setBorder(0); PdfPCell celdaValor = new PdfPCell(new Phrase(value, colorLetra)); celdaValor.setColspan(5); celdaValor.setBorder(0); body.addCell(celdaEnBlanco); body.addCell(celdaKey); body.addCell(celdaValor); body.addCell(celdaEnBlanco); } return body; }
public void createTable(Section subCatPart) throws BadElementException { PdfPTable table = new PdfPTable(3); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); PdfPCell c1 = new PdfPCell(new Phrase("Table Header 1")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Table Header 2")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Table Header 3")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); table.addCell("1.0"); table.addCell("1.1"); table.addCell("1.2"); table.addCell("2.1"); table.addCell("2.2"); table.addCell("2.3"); subCatPart.add(table); }
public void createPdf(String dest) throws IOException, DocumentException { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(dest)); document.open(); PdfPTable table = new PdfPTable(8); PdfPCell cell = new PdfPCell(new Phrase("hi")); cell.setRowspan(2); table.addCell(cell); for (int aw = 0; aw < 14; aw++) { table.addCell("hi"); } document.add(table); document.close(); }
@Override public void addContent(PdfPTable table, Font font, IWeaponStats weapon) { if (weapon == null) { table.addCell(createEmptyNameCell(font)); } else { Stream<Identifier> tags = weapon.getTags().stream(); List<String> values = tags.filter(printedTags::contains) .map(input -> resources.getString("Weapons.Tags." + input.getId() + ".Short")) .collect(toList()); String valueString = values.isEmpty() ? " " : Joiner.on(",").join(values); table.addCell(createFilledContentCell(font, valueString)); } }
private PdfPTable createCommonActionsTable(SheetGraphics graphics, CombatStatsContent content) { float[] columnWidths = new float[] {5f, 1.5f, 1.5f}; PdfPTable table = new PdfPTable(columnWidths); table.setWidthPercentage(100); String header = content.getActionHeader(); TableCell headerCell = createCommonActionsCell(new Phrase(header, graphics.createTextFont())); headerCell.setColspan(columnWidths.length); table.addCell(headerCell); for (CombatAction combatAction : content.getCombatActions()) { addCommonActionsCell(graphics, table, combatAction.name); addCommonActionsCell(graphics, table, combatAction.speed); addCommonActionsCell(graphics, table, combatAction.dv); } return table; }
private PdfPTable getHeader() throws DocumentException, IOException { PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100); Image image = Image.getInstance(getClass().getResource("/images/SLA_header.png")); image.scalePercent(42); PdfPCell cell = new PdfPCell(image); cell.setBorder(0); cell.setPadding(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); return table; }
private void addBuyerAndSeller(Document document, Examination examination) throws DocumentException { PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); PdfPCell seller = getPartyAddress("Kibocsátó:", "Ceg neve", "Ceg Varosa", "Ceg cime"); table.addCell(seller); PdfPCell buyer = getPartyAddress( "Vevő:", examination.getPatient().getName(), examination.getPatient().getCity(), examination.getPatient().getAddress()); table.addCell(buyer); document.add(table); }
@Override protected PdfPTable createTable(SheetGraphics graphics, ReportSession session, Bounds bounds) { ColumnDescriptor[] columns = getColumns(); PdfPTable table = new PdfPTable(getColumnWidths(columns)); table.setWidthPercentage(100); for (ColumnDescriptor column : columns) { table.addCell(createHeaderCell(graphics, getString(column.getHeaderKey()))); } CharacterType type = session.getHero().getTemplate().getTemplateType().getCharacterType(); String descriptionPrefix = "Sheet.AnimaTable.Description." + type.getId(); for (int index = 0; index < 5; index++) { addAnimaRow(graphics, table, index, session, descriptionPrefix); } return table; }
public void columnBreak() { if (colIdx + 1 < layoutTable.getNumberOfColumns()) { setColIdx(colIdx + 1); } else { pageBreak(); } }
private void tableContent(List<Computer> computerList) { float[] colsWidth = {1f, 1f, 1f}; table = new PdfPTable(colsWidth); table.setWidthPercentage(100); // pdf header String[] headerArr = {"Computer Name", "GA-NO.", "Catalog"}; for (String header : headerArr) addTableHeader(header); // pdf content PdfPCell cell = new PdfPCell(); for (Computer computer : computerList) { String catalogStr = null, name = computer.getName(); tableAddCell(cell, name); tableAddCell(cell, computer.getGaNo()); int catalog = computer.getCatalog(); switch (catalog) { case 0: catalogStr = name.contains("BCP") ? "W & BCP" : "W & P"; break; case 1: catalogStr = "SVR & P"; break; case 2: catalogStr = "STD"; } tableAddCell(cell, catalogStr); } }
public static void agregarMatrizPDF() { PdfPTable table = new PdfPTable(matriz[0].length + 3); FileOutputStream archivo = null; try { archivo = new FileOutputStream("tmp.pdf"); } catch (FileNotFoundException ex) { Logger.getLogger(principal.class.getName()).log(Level.SEVERE, null, ex); } Document documento = new Document(); try { PdfWriter.getInstance(documento, archivo); } catch (DocumentException ex) { Logger.getLogger(principal.class.getName()).log(Level.SEVERE, null, ex); } documento.open(); try { documento.add(new Paragraph("Gran M\n")); } catch (DocumentException ex) { Logger.getLogger(principal.class.getName()).log(Level.SEVERE, null, ex); } for (int i = 0; i < labelMatriz.length; i++) { table.addCell(labelMatriz[i].getText()); } for (int i = 0; i < (matriz.length); i++) { for (int k = 0; k < (matriz[0].length + 3); k++) { if (k < 3) { table.addCell(rvz[i][k].toString()); } else { table.addCell(matriz[i][k - 3].toString()); } } } try { if (documento.isOpen()) { documento.add(table); } } catch (DocumentException ex) { Logger.getLogger(principal.class.getName()).log(Level.SEVERE, null, ex); } documento.close(); }
/** * Creates a PDF document. * * @param filename the path to the new PDF document * @param locale Locale in case you want to create a Calendar in another language * @param year the year for which you want to make a calendar * @throws DocumentException * @throws IOException */ public void createPdf(String filename, Locale locale, int year) throws IOException, DocumentException { // step 1 Document document = new Document(PageSize.A4.rotate()); // step 2 PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); // step 3 document.open(); // step 4 PdfPTable table; Calendar calendar; PdfContentByte canvas = writer.getDirectContent(); // Loop over the months for (int month = 0; month < 12; month++) { calendar = new GregorianCalendar(year, month, 1); // draw the background drawImageAndText(canvas, calendar); // create a table with 7 columns table = new PdfPTable(7); table.setTableEvent(tableBackground); table.setTotalWidth(504); // add the name of the month table.getDefaultCell().setBorder(PdfPCell.NO_BORDER); table.getDefaultCell().setCellEvent(whiteRectangle); table.addCell(getMonthCell(calendar, locale)); int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); int day = 1; int position = 2; // add empty cells while (position != calendar.get(Calendar.DAY_OF_WEEK)) { position = (position % 7) + 1; table.addCell(""); } // add cells for each day while (day <= daysInMonth) { calendar = new GregorianCalendar(year, month, day++); table.addCell(getDayCell(calendar, locale)); } // complete the table table.completeRow(); // write the table to an absolute position table.writeSelectedRows(0, -1, 169, table.getTotalHeight() + 20, canvas); document.newPage(); } // step 5 document.close(); }
public static void clearTable(PdfPTable table, boolean resetFixedHeight) { for (PdfPCell cell : table.getRow(0).getCells()) { cell.setColumn(createColumnText()); if (resetFixedHeight) { cell.setFixedHeight(-1.0f); } } }
public static void replaceTableCells(PdfPTable table) { // replace default table cells // by fixed height cells PdfPCell[] cells = table.getRow(0).getCells(); for (int i = 0; i < cells.length; i++) { cells[i] = new FixedHeightPdfPCell(cells[i]); } }
@Override public void addContent(PdfPTable table, Font font, IShieldStats shield) { PdfPCell cell = TableEncodingUtilities.createContentCellTable( null, getResources().getString("Sheet.Equipment.Header.RangeBonus"), // $NON-NLS-1$ font, 0f, Rectangle.NO_BORDER, Element.ALIGN_LEFT); table.addCell(cell); if (shield == null) { table.addCell(createFinalValueCell(font)); } else { table.addCell(createFinalValueCell(font, shield.getRangedCombatBonus())); } }
private static void addTitle( Document document, PdfWriter writer, String fieldName, String headerText) throws Exception, IOException, BadElementException { log.log(Level.INFO, "ApplicationFormPDFMaintenance --> addTitle "); PdfPTable table = new PdfPTable(2); PdfPCell c1 = new PdfPCell(new Phrase(headerText)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_CENTER); // c1.setBackgroundColor(BaseColor.RED); c1.setBorder(Rectangle.BOX); c1.setFixedHeight(25f); c1.setColspan(2); table.addCell(c1); table.setWidthPercentage(100f); document.add(table); }
@Override protected void addFirstCell( SheetGraphics graphics, ReportContent reportContent, PdfPTable table) { CombatStatsContent content = reportContent.createSubContent(CombatStatsContent.class); TableCell cell = new TableCell(createCombatAttackList(graphics, content), Rectangle.BOX); cell.setPaddingBottom(2f); table.addCell(cell); }