List of usage examples for com.lowagie.text.pdf PdfPCell setVerticalAlignment
public void setVerticalAlignment(int verticalAlignment)
From source file:com.qcadoo.mes.deliveries.print.OrderReportPdf.java
License:Open Source License
private void addTotalRow(final PdfPTable productsTable, final Locale locale, final List<String> columnsName, Entity delivery) {/*from w w w. jav a 2 s .com*/ DeliveryPricesAndQuantities deliveryPricesAndQuantities = new DeliveryPricesAndQuantities(delivery, numberService); PdfPCell total = new PdfPCell( new Phrase(translationService.translate("deliveries.delivery.report.totalCost", locale), FontUtils.getDejavuRegular7Dark())); total.setColspan(2); total.setHorizontalAlignment(Element.ALIGN_LEFT); total.setVerticalAlignment(Element.ALIGN_MIDDLE); total.setBackgroundColor(null); total.disableBorderSide(Rectangle.RIGHT); total.disableBorderSide(Rectangle.LEFT); total.setBorderColor(ColorUtils.getLineLightColor()); productsTable.addCell(total); for (int i = 2; i < columnsName.size(); i++) { if (columnsName.contains(OrderedProductFields.ORDERED_QUANTITY) && columnsName.indexOf(OrderedProductFields.ORDERED_QUANTITY) == i) { productsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); productsTable.addCell( new Phrase(numberService.format(deliveryPricesAndQuantities.getOrderedCumulatedQuantity()), FontUtils.getDejavuRegular7Dark())); } else if (columnsName.contains(OrderedProductFields.TOTAL_PRICE) && columnsName.indexOf(OrderedProductFields.TOTAL_PRICE) == i) { productsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); productsTable.addCell( new Phrase(numberService.format(deliveryPricesAndQuantities.getOrderedTotalPrice()), FontUtils.getDejavuRegular7Dark())); } else if (columnsName.contains(L_CURRENCY) && columnsName.indexOf(L_CURRENCY) == i) { productsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); productsTable.addCell( new Phrase(deliveriesService.getCurrency(delivery), FontUtils.getDejavuRegular7Dark())); } else { productsTable.addCell(""); } } }
From source file:com.qcadoo.mes.workPlans.pdf.document.WorkPlanPdfForDivision.java
License:Open Source License
private void addOperationTable(PdfWriter pdfWriter, GroupingContainer groupingContainer, Document document, OrderOperationComponent orderOperationComponent, Locale locale) throws DocumentException { Map<Long, Map<OperationProductColumn, ColumnAlignment>> outputProductsMap = groupingContainer .getOperationComponentIdProductOutColumnToAlignment(); Map<Long, Map<OperationProductColumn, ColumnAlignment>> inputProductsMap = groupingContainer .getOperationComponentIdProductInColumnToAlignment(); Entity operationComponent = orderOperationComponent.getOperationComponent(); Entity order = orderOperationComponent.getOrder(); Entity product = order.getBelongsToField(OrderFields.PRODUCT); Map<OperationProductColumn, ColumnAlignment> inputProductColumnAlignmentMap = inputProductsMap .get(operationComponent.getId()); Map<OperationProductColumn, ColumnAlignment> outputProductColumnAlignmentMap = outputProductsMap .get(operationComponent.getId()); PdfPTable table = pdfHelper.createPanelTable(3); PdfPCell headerCell = new PdfPCell(); headerCell.setBorder(Rectangle.NO_BORDER); headerCell.setColspan(2);/*from www .ja v a 2 s. c o m*/ PdfPCell inputCell = new PdfPCell(); inputCell.setBorder(Rectangle.NO_BORDER); PdfPCell outputCell = new PdfPCell(); outputCell.setBorder(Rectangle.NO_BORDER); PdfPCell codeCell = new PdfPCell(); codeCell.setBorder(Rectangle.NO_BORDER); codeCell.setHorizontalAlignment(Element.ALIGN_CENTER); codeCell.setVerticalAlignment(Element.ALIGN_TOP); codeCell.setRowspan(2); // addOperationSummary(headerCell, operationComponent); addOrderSummary(headerCell, order, product, operationComponent); addOperationProductsTable(inputCell, operationProductInComponents(operationComponent, order), inputProductColumnAlignmentMap, ProductDirection.IN, locale); addOperationProductsTable(outputCell, operationProductOutComponents(operationComponent, order), outputProductColumnAlignmentMap, ProductDirection.OUT, locale); codeCell.addElement(createBarcode(pdfWriter, operationComponent)); float[] tableColumnWidths = new float[] { 70f, 70f, 10f }; table.setWidths(tableColumnWidths); table.setTableEvent(null); table.addCell(headerCell); table.addCell(codeCell); table.addCell(inputCell); table.addCell(outputCell); table.setKeepTogether(true); document.add(table); }
From source file:com.silverpeas.kmelia.workflowextensions.SendInKmelia.java
License:Open Source License
private void generatePDFStepHeader(HistoryStep step, com.lowagie.text.Document document) { try {// w w w . j a v a 2s . c o m String activity = ""; if (step.getResolvedState() != null) { State resolvedState = step.getProcessInstance().getProcessModel().getState(step.getResolvedState()); activity = resolvedState.getLabel(getRole(), getLanguage()); } String sAction = null; try { if ("#question#".equals(step.getAction())) { sAction = getString("processManager.question"); } else if ("#response#".equals(step.getAction())) { sAction = getString("processManager.response"); } else if ("#reAssign#".equals(step.getAction())) { sAction = getString("processManager.reAffectation"); } else { Action action = step.getProcessInstance().getProcessModel().getAction(step.getAction()); sAction = action.getLabel(getRole(), getLanguage()); } } catch (WorkflowException we) { sAction = "##"; } String actor = getBestUserDetail().getDisplayedName(); String date = DateUtil.getOutputDateAndHour(step.getActionDate(), getLanguage()); String header = ""; if (StringUtil.isDefined(activity)) { header += activity + " - "; } header += sAction + " (" + actor + " - " + date + ")"; Font fontHeader = new Font(Font.HELVETICA, 12, Font.NORMAL); PdfPCell pCell = new PdfPCell(new Phrase(header, fontHeader)); pCell.setFixedHeight(28); pCell.setBackgroundColor(new Color(239, 239, 239)); pCell.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPTable pTable = new PdfPTable(1); pTable.setWidthPercentage(100); pTable.addCell(pCell); document.add(pTable); } catch (Exception e) { SilverTrace.error("workflowEngine", "SendInKmelia.generatePDFStep()", "root.MSG_GEN_ERROR", e); } }
From source file:com.slamd.report.PDFReportGenerator.java
License:Open Source License
/** * Performs the appropriate action necessary when starting a new page. In * this case, we will write the SLAMD header to the top of the page. * * @param writer The writer used to write the PDF document. * @param document The PDF document being written. */// w w w .j av a 2 s. c o m public void onStartPage(PdfWriter writer, Document document) { try { PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100); PdfPCell blueCell = new PdfPCell(new Phrase(" \n ")); blueCell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); blueCell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); blueCell.setBackgroundColor(new Color(0x59, 0x4F, 0xBF)); blueCell.setBorderWidth(inchesToPoints(1.0 / 16)); blueCell.setBorderColor(new Color(0xFF, 0xFF, 0xFF)); blueCell.setPadding(inchesToPoints(1.0 / 16)); table.addCell(blueCell); Phrase titlePhrase = new Phrase("SLAMD Generated Report", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0x59, 0x4F, 0xBF))); PdfPCell yellowCell = new PdfPCell(titlePhrase); yellowCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); yellowCell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); yellowCell.setBackgroundColor(new Color(0xFB, 0xE2, 0x49)); yellowCell.setBorderWidth(inchesToPoints(1.0 / 16)); yellowCell.setBorderColor(new Color(0xFF, 0xFF, 0xFF)); yellowCell.setPadding(inchesToPoints(1.0 / 16)); table.addCell(yellowCell); Phrase versionPhrase = new Phrase("Version " + DynamicConstants.SLAMD_VERSION, FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0xFF, 0xFF, 0xFF))); PdfPCell redCell = new PdfPCell(versionPhrase); redCell.setHorizontalAlignment(Cell.ALIGN_RIGHT); redCell.setVerticalAlignment(Cell.ALIGN_MIDDLE); redCell.setBackgroundColor(new Color(0xD1, 0x21, 0x24)); redCell.setBorderWidth(inchesToPoints(1.0 / 16)); redCell.setBorderColor(new Color(0xFF, 0xFF, 0xFF)); redCell.setPadding(inchesToPoints(1.0 / 16)); table.addCell(redCell); document.add(table); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.songbook.pc.exporter.PdfExporter.java
License:Open Source License
private Element buildQrCodeSection() throws IOException, DocumentException { // Load images Image qrApkImage = PngImage//www .j a v a 2 s .c o m .getImage(PdfExporter.class.getResourceAsStream("/export/qr/songbook_apk_qr.png")); Image qrPdfImage = PngImage .getImage(PdfExporter.class.getResourceAsStream("/export/qr/songbook_pdf_qr.png")); PdfPCell cell = new PdfPCell((Phrase) null); cell.setBorder(PdfPCell.NO_BORDER); cell.setVerticalAlignment(PdfPCell.ALIGN_CENTER); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); PdfPTable table = new PdfPTable(3); table.setWidthPercentage(100); table.setWidths(new float[] { 1, 2, 1 }); cell.setImage(qrApkImage); table.addCell(cell); cell.setImage(null); table.addCell(cell); cell.setImage(qrPdfImage); table.addCell(cell); cell.setImage(null); cell.setPhrase(new Phrase("APP")); table.addCell(cell); cell.setPhrase(null); table.addCell(cell); cell.setPhrase(new Phrase("PDF")); table.addCell(cell); cell.setPhrase(null); return table; }
From source file:corner.orm.tapestry.pdf.components.AbstractPdfTableDisplay.java
License:Apache License
/** * PdfPTableHeader/*from w w w.j av a 2 s.c o m*/ * * @param table */ protected void beginTableHeader(PdfPTable table) { // if (this.getDisplayTableModel().getHeaders() != null) { Font headerFont = this.getDisplayTableModel().getHeadersFont(); if (headerFont == null) {//footer headerFont = PdfUtils.createHeaderSongLightFont(10); } for (int i = 0; i < getDisplayTableModel().getColumnCount(); i++) { // TODO ?? PdfPCell cell = new PdfPCell(new Phrase(getDisplayTableModel().getHeaders()[i], headerFont)); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);// cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);// table.addCell(cell); } } }
From source file:corner.orm.tapestry.pdf.components.AbstractPdfTableDisplay.java
License:Apache License
/** * PdfPTableFooter/*from w w w . j a v a 2s . c o m*/ * * @param table */ protected void beginTableFooter(PdfPTable table, PdfWriter writer) { if (this.getDisplayTableModel().getFooters() != null) { List<String> cells = this.getDisplayTableModel().getFooters(); Font footerFont = this.getDisplayTableModel().getFootersFont(); if (footerFont == null) {//footer footerFont = PdfUtils.createHeaderSongLightFont(10); } Iterator<String> it = cells.iterator(); while (it.hasNext()) { String key = it.next(); // TODO ?? PdfPCell cell = new PdfPCell(new Phrase(key, footerFont)); cell.setColspan(getDisplayTableModel().getColumnCount()); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);// ?? cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);// table.addCell(cell); } } }
From source file:de.dhbw.humbuch.util.PDFHandler.java
/** * Set the logo of Humboldt on the left corner and the current date on the * right corner//from w w w .j a v a 2 s .co m * * @param document * reference of the pdfDocument object */ protected void addHeading(Document document) { Paragraph paragraph = new Paragraph(); PdfPTable table = createMyStandardTable(2); table.setTotalWidth(TABLEWIDTH); PdfPCell cell; Image img = new ResourceLoader("pdf/humboldt_logo.png").getImage(); img.setAlignment(Element.ALIGN_BOTTOM); img.scaleToFit(205f, 65f); cell = new PdfPCell(img); cell.setBorder(0); table.addCell(cell); String date = new SimpleDateFormat("dd.MM.yyyy", Locale.GERMAN).format(Calendar.getInstance().getTime()); cell = new PdfPCell(new Phrase(date)); cell.setBorder(0); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setBorder(Rectangle.BOTTOM); table.addCell(cell); cell = new PdfPCell(new Phrase("")); cell.setBorder(Rectangle.BOTTOM); table.addCell(cell); paragraph.add(table); addEmptyLine(paragraph, 1); try { document.add(paragraph); } catch (DocumentException e) { e.printStackTrace(); } }
From source file:de.dhbw.humbuch.util.PDFHandler.java
/** * Use the configuration information to fill the table cells * @param tableBuilder Table configuration *//* w ww. j a v a 2s .com*/ private static void fillTableWithContent(TableBuilder tableBuilder) { PdfPCell cell = null; for (int i = 0; i < tableBuilder.contentArray.length; i++) { if (tableBuilder.contentArray[i] == null || tableBuilder.contentArray[i].equals("null")) { tableBuilder.contentArray[i] = ""; } if (tableBuilder.font != null) { cell = new PdfPCell(new Phrase(tableBuilder.contentArray[i], tableBuilder.font)); } else { cell = new PdfPCell(new Phrase(tableBuilder.contentArray[i])); } if (tableBuilder.isAlignedCentrally) { cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); } if (!tableBuilder.withBorder) { cell.setBorder(0); } if (tableBuilder.padding != 0f) { cell.setPadding(tableBuilder.padding); } if (tableBuilder.leading != 0f) { cell.setLeading(tableBuilder.leading, tableBuilder.leading); } tableBuilder.table.addCell(cell); } }
From source file:de.jdufner.sudoku.generator.pdf.PdfCellHandler.java
License:Open Source License
private void formatZelle(final int zeile, final int spalte, final PdfPCell cell) { cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBorderColor(new Color(// Integer.parseInt(getPdfStyle().getProperty("sudoku.board.border.color.red")), // Integer.parseInt(getPdfStyle().getProperty("sudoku.board.border.color.green")), // Integer.parseInt(getPdfStyle().getProperty("sudoku.board.border.color.blue")))); if (isEvenBlockIndex(zeile, spalte)) { cell.setBackgroundColor(new Color(// Integer.parseInt(getPdfStyle().getProperty("sudoku.board.background.odd.color.red")), // Integer.parseInt(getPdfStyle().getProperty("sudoku.board.background.odd.color.green")), // Integer.parseInt(getPdfStyle().getProperty("sudoku.board.background.odd.color.blue")))); } else {/*from w w w .j a v a 2 s . c o m*/ cell.setBackgroundColor(new Color(// Integer.parseInt(getPdfStyle().getProperty("sudoku.board.background.even.color.red")), // Integer.parseInt(getPdfStyle().getProperty("sudoku.board.background.even.color.green")), // Integer.parseInt(getPdfStyle().getProperty("sudoku.board.background.even.color.blue")))); } cell.setBorderWidth(PdfConstants.RAHMEN_DUENN); if (BoxUtils.isFirstRowInBlock(zeile, getSudokuSize())) { cell.setBorderWidthTop(PdfConstants.RAHMEN_DICK); } else { cell.setBorderWidthTop(PdfConstants.RAHMEN_DUENN); } if (BoxUtils.isLastColumnInRow(spalte, getSudokuSize())) { cell.setBorderWidthRight(PdfConstants.RAHMEN_DICK); } else { cell.setBorderWidthRight(PdfConstants.RAHMEN_DUENN); } if (BoxUtils.isLastRowInColumn(zeile, getSudokuSize())) { cell.setBorderWidthBottom(PdfConstants.RAHMEN_DICK); } else { cell.setBorderWidthBottom(PdfConstants.RAHMEN_DUENN); } if (BoxUtils.isFirstColumnInBlock(spalte, getSudokuSize())) { cell.setBorderWidthLeft(PdfConstants.RAHMEN_DICK); } else { cell.setBorderWidthLeft(PdfConstants.RAHMEN_DUENN); } cell.setFixedHeight(27f); }