List of usage examples for com.lowagie.text.pdf PdfPTable addCell
public void addCell(Phrase phrase)
From source file:com.qcadoo.mes.warehouseMinimalState.print.DocumentPdf.java
License:Open Source License
public void addSmallCell(PdfPTable table, BigDecimal content) { PdfPCell cell = new PdfPCell(table.getDefaultCell()); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); String value = numberService.formatWithMinimumFractionDigits(content, 0); cell.setPhrase(new Phrase(value, FontUtils.getDejavuRegular7Dark())); table.addCell(cell); }
From source file:com.qcadoo.mes.workPlans.pdf.document.operation.component.OperationBarcode.java
License:Open Source License
public void print(PdfWriter pdfWriter, Entity operationComponent, Document document) throws DocumentException { PdfContentByte cb = pdfWriter.getDirectContent(); Barcode128 code128 = new Barcode128(); code128.setCode(// ww w.j a va2 s . com barcodeOperationComponentService.getCodeFromBarcodeForOperationComponet(operationComponent)); PdfPTable barcodeTable = new PdfPTable(1); barcodeTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); barcodeTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP); barcodeTable.getDefaultCell().setBorder(0); barcodeTable.setWidthPercentage(10f); barcodeTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); Image barcodeImage = code128.createImageWithBarcode(cb, null, null); barcodeTable.addCell(barcodeImage); document.add(barcodeTable); }
From source file:com.qcadoo.mes.workPlans.pdf.document.operation.component.OperationProductInTable.java
License:Open Source License
public void print(GroupingContainer groupingContainer, Entity operationComponent, Document document, Locale locale) throws DocumentException { Map<Long, Map<OperationProductColumn, ColumnAlignment>> map = groupingContainer .getOperationComponentIdProductInColumnToAlignment(); Map<OperationProductColumn, ColumnAlignment> operationProductColumnAlignmentMap = map .get(operationComponent.getId()); int columnCount = operationProductColumnAlignmentMap.size(); Map<String, HeaderAlignment> headerAlignments = new HashMap<String, HeaderAlignment>(columnCount); List<String> headers = new ArrayList<String>(columnCount); fill(locale, operationProductColumnAlignmentMap, headers, headerAlignments); PdfPTable table = pdfHelper.createTableWithHeader(columnCount, headers, false, headerAlignments); PdfPCell defaultCell = table.getDefaultCell(); for (Entity operationProduct : operationProductInComponents(operationComponent)) { for (Map.Entry<OperationProductColumn, ColumnAlignment> e : operationProductColumnAlignmentMap .entrySet()) {// w w w . j ava 2 s .c o m alignColumn(defaultCell, e.getValue()); table.addCell(operationProductPhrase(operationProduct, e.getKey())); } } int additionalRows = workPlansService .getAdditionalRowsFromParameter(ParameterFieldsWP.ADDITIONAL_INPUT_ROWS); for (int i = 0; i < additionalRows; i++) { for (Map.Entry<OperationProductColumn, ColumnAlignment> e : operationProductColumnAlignmentMap .entrySet()) { alignColumn(defaultCell, e.getValue()); table.addCell(" "); } } table.setSpacingAfter(18); table.setSpacingBefore(9); document.add(table); }
From source file:com.qcadoo.mes.workPlans.pdf.document.operation.component.OperationProductOutTable.java
License:Open Source License
public void print(GroupingContainer groupingContainer, Entity operationComponent, Document document, Locale locale) throws DocumentException { Map<Long, Map<OperationProductColumn, ColumnAlignment>> map = groupingContainer .getOperationComponentIdProductInColumnToAlignment(); Map<OperationProductColumn, ColumnAlignment> operationProductColumnAlignmentMap = map .get(operationComponent.getId()); int columnCount = operationProductColumnAlignmentMap.size(); Map<String, HeaderAlignment> headerAlignments = new HashMap<String, HeaderAlignment>(columnCount); List<String> headers = new ArrayList<String>(columnCount); fill(locale, operationProductColumnAlignmentMap, headers, headerAlignments); PdfPTable table = pdfHelper.createTableWithHeader(columnCount, headers, false, headerAlignments); PdfPCell defaultCell = table.getDefaultCell(); for (Entity operationProduct : operationProductOutComponents(operationComponent)) { for (Map.Entry<OperationProductColumn, ColumnAlignment> e : operationProductColumnAlignmentMap .entrySet()) {//from ww w . j a v a 2s . com alignColumn(defaultCell, e.getValue()); table.addCell(operationProductPhrase(operationProduct, e.getKey())); } } int additionalRows = workPlansService .getAdditionalRowsFromParameter(ParameterFieldsWP.ADDITIONAL_OUTPUT_ROWS); for (int i = 0; i < additionalRows; i++) { for (Map.Entry<OperationProductColumn, ColumnAlignment> e : operationProductColumnAlignmentMap .entrySet()) { alignColumn(defaultCell, e.getValue()); table.addCell(" "); } } table.setSpacingAfter(18); table.setSpacingBefore(9); document.add(table); }
From source file:com.qcadoo.mes.workPlans.pdf.document.order.component.OrderTable.java
License:Open Source License
public void print(GroupingContainer groupingContainer, Document document, Locale locale) throws DocumentException { document.add(ordersTableHeaderParagraph(locale)); Map<OrderColumn, ColumnAlignment> orderColumnToAlignment = groupingContainer.getOrderColumnToAlignment(); int columnCount = orderColumnToAlignment.size(); Map<String, HeaderAlignment> headerAlignments = new HashMap<String, HeaderAlignment>(columnCount); List<String> headers = new ArrayList<String>(columnCount); fill(locale, orderColumnToAlignment, headers, headerAlignments); PdfPTable orderTable = pdfHelper.createTableWithHeader(columnCount, headers, false, headerAlignments); PdfPCell defaultCell = orderTable.getDefaultCell(); for (Entity order : groupingContainer.getOrders()) { for (Map.Entry<OrderColumn, ColumnAlignment> e : orderColumnToAlignment.entrySet()) { alignColumn(defaultCell, e.getValue()); orderTable.addCell(orderColumnValuePhrase(order, e.getKey())); }/* w w w. j av a 2s .co m*/ } document.add(orderTable); document.add(Chunk.NEWLINE); }
From source file:com.qcadoo.mes.workPlans.pdf.document.WorkPlanPdfForDivision.java
License:Open Source License
private void addWorkPlanTitle(Document document, Entity workPlan, String title, Locale locale) throws DocumentException { PdfPTable headerTable = pdfHelper.createPanelTable(2); PdfPCell titleCell = new PdfPCell(); titleCell.setBorder(Rectangle.NO_BORDER); Paragraph workPlanTitle = new Paragraph( new Phrase(getWorkPlanTitle(locale), FontUtils.getDejavuBold11Light())); workPlanTitle.add(new Phrase(" " + getWorkPlanName(workPlan), FontUtils.getDejavuBold11Dark())); titleCell.addElement(workPlanTitle); PdfPCell divisionCell = new PdfPCell(); divisionCell.setBorder(Rectangle.NO_BORDER); Paragraph divisionTitle = new Paragraph( new Phrase(getDivisionTitle(locale), FontUtils.getDejavuBold11Light())); divisionTitle.add(new Phrase(" " + getDivisionFromTitle(title, locale), FontUtils.getDejavuBold11Dark())); divisionTitle.setAlignment(Element.ALIGN_RIGHT); divisionCell.addElement(divisionTitle); headerTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); headerTable.setTableEvent(null);//w ww . j av a 2 s. c o m headerTable.setSpacingAfter(4.0f); headerTable.addCell(titleCell); headerTable.addCell(divisionCell); document.add(headerTable); }
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 ww w . j av 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.qcadoo.mes.workPlans.pdf.document.WorkPlanPdfForDivision.java
License:Open Source License
private void addOperationSummary(PdfPCell cell, Entity operationComponent) throws DocumentException { Entity operation = operationComponent.getBelongsToField(TechnologyOperationComponentFields.OPERATION); PdfPTable operationTable = pdfHelper.createPanelTable(1); PdfPCell numberCell = new PdfPCell(); numberCell.setBorder(Rectangle.NO_BORDER); Paragraph operationName = new Paragraph(operation.getStringField(OperationFields.NUMBER) + " - " + operation.getStringField(OperationFields.NAME), FontUtils.getDejavuBold7Dark()); numberCell.addElement(operationName); PdfPCell descriptionCell = new PdfPCell(); descriptionCell.setBorder(Rectangle.NO_BORDER); String comment = operation.getStringField(OperationFields.COMMENT); Paragraph description = null;/*from w ww .j a va2s. c o m*/ if (!StringUtils.isEmpty(comment)) { description = new Paragraph(comment, FontUtils.getDejavuBold7Dark()); } operationTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); operationTable.setTableEvent(null); operationTable.addCell(numberCell); if (description != null) { descriptionCell.addElement(description); operationTable.addCell(descriptionCell); } else { operationTable.addCell(""); } cell.addElement(operationTable); }
From source file:com.qcadoo.mes.workPlans.pdf.document.WorkPlanPdfForDivision.java
License:Open Source License
private void addOrderSummary(PdfPCell cell, Entity order, Entity product, Entity operationComponent) throws DocumentException { Entity operation = operationComponent.getBelongsToField(TechnologyOperationComponentFields.OPERATION); PdfPTable orderTable = pdfHelper.createPanelTable(3); PdfPCell operationCell = new PdfPCell(); operationCell.setBorder(Rectangle.NO_BORDER); Paragraph operationName = new Paragraph(operation.getStringField(OperationFields.NUMBER) + " - " + operation.getStringField(OperationFields.NAME), FontUtils.getDejavuBold7Dark()); operationCell.addElement(operationName); PdfPCell numberCell = new PdfPCell(); numberCell.setBorder(Rectangle.NO_BORDER); Paragraph number = new Paragraph(order.getStringField(OrderFields.NUMBER), FontUtils.getDejavuBold7Dark()); number.setAlignment(Element.ALIGN_RIGHT); numberCell.addElement(number);//from w w w . j a v a 2 s.c o m PdfPCell quantityCell = new PdfPCell(); quantityCell.setBorder(Rectangle.NO_BORDER); Paragraph quantity = new Paragraph( numberService.formatWithMinimumFractionDigits(order.getDecimalField(OrderFields.PLANNED_QUANTITY), 0) + " " + product.getStringField(ProductFields.UNIT), FontUtils.getDejavuBold7Dark()); quantity.setAlignment(Element.ALIGN_CENTER); quantityCell.addElement(quantity); PdfPCell descriptionCell = new PdfPCell(); descriptionCell.setBorder(Rectangle.NO_BORDER); descriptionCell.setColspan(3); String comment = operationComponent.getStringField(TechnologyOperationComponentFields.COMMENT); Paragraph description = null; if (!StringUtils.isEmpty(comment)) { description = new Paragraph(comment, FontUtils.getDejavuBold7Dark()); } float[] tableColumnWidths = new float[] { 160f, 30f, 10f }; orderTable.setWidths(tableColumnWidths); orderTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); orderTable.setTableEvent(null); orderTable.addCell(operationCell); orderTable.addCell(numberCell); orderTable.addCell(quantityCell); if (description != null) { descriptionCell.addElement(description); orderTable.addCell(descriptionCell); } cell.addElement(orderTable); }
From source file:com.qcadoo.mes.workPlans.pdf.document.WorkPlanPdfForDivision.java
License:Open Source License
private void addOperationProductsTable(PdfPCell cell, List<Entity> operationProductComponents, Map<OperationProductColumn, ColumnAlignment> operationProductColumnAlignmentMap, ProductDirection direction, Locale locale) throws DocumentException { if (operationProductComponents.isEmpty()) { return;// w w w .j av a 2s . c om } int columnCount = operationProductColumnAlignmentMap.size(); Map<String, HeaderAlignment> headerAlignments = new HashMap<String, HeaderAlignment>(columnCount); List<String> headers = new ArrayList<String>(columnCount); float[] widths = fill(locale, operationProductColumnAlignmentMap, headers, headerAlignments, direction); PdfPTable table = pdfHelper.createTableWithHeader(columnCount, headers, false, headerAlignments); table.setWidths(widths); PdfPCell defaultCell = table.getDefaultCell(); for (Entity operationProduct : operationProductComponents) { for (Map.Entry<OperationProductColumn, ColumnAlignment> e : operationProductColumnAlignmentMap .entrySet()) { alignColumn(defaultCell, e.getValue()); table.addCell(operationProductPhrase(operationProduct, e.getKey())); } } cell.addElement(table); }