List of usage examples for com.lowagie.text.pdf PdfPTable getDefaultCell
public PdfPCell getDefaultCell()
PdfPCell
that will be used as reference for all the addCell
methods except addCell(PdfPCell)
. From source file:com.qcadoo.mes.simpleMaterialBalance.internal.print.SimpleMaterialBalancePdfService.java
License:Open Source License
private void addBalance(final Document document, final Entity simpleMaterialBalance, final Locale locale) throws DocumentException { document.add(new Paragraph( translationService.translate("simpleMaterialBalance.simpleMaterialBalance.report.paragrah", locale), FontUtils.getDejavuBold11Dark())); List<String> simpleMaterialBalanceTableHeader = new ArrayList<String>(); simpleMaterialBalanceTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.number", locale)); simpleMaterialBalanceTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.name", locale)); simpleMaterialBalanceTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.needed", locale)); simpleMaterialBalanceTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.inLocation", locale)); simpleMaterialBalanceTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.balance", locale)); simpleMaterialBalanceTableHeader.add(translationService.translate("basic.product.unit.label", locale)); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); alignments.put(/* ww w. j a va 2 s. co m*/ translationService.translate( "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.number", locale), HeaderAlignment.LEFT); alignments.put(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.name", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate( "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.needed", locale), HeaderAlignment.RIGHT); alignments.put( translationService.translate( "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.inLocation", locale), HeaderAlignment.RIGHT); alignments.put( translationService.translate( "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.balance", locale), HeaderAlignment.RIGHT); alignments.put(translationService.translate("basic.product.unit.label", locale), HeaderAlignment.LEFT); PdfPTable table = pdfHelper.createTableWithHeader(6, simpleMaterialBalanceTableHeader, false, alignments); List<Entity> simpleMaterialBalanceOrdersComponents = simpleMaterialBalance .getHasManyField(L_SIMPLE_MATERIAL_BALANCE_ORDERS_COMPONENTS); MrpAlgorithm mrpAlgorithm = MrpAlgorithm.parseString(simpleMaterialBalance.getStringField("mrpAlgorithm")); Map<Long, BigDecimal> neededProductQuantities = productQuantitiesService .getNeededProductQuantitiesForComponents(simpleMaterialBalanceOrdersComponents, mrpAlgorithm); List<Entity> simpleMaterialBalanceLocationComponents = simpleMaterialBalance .getHasManyField(L_SIMPLE_MATERIAL_BALANCE_LOCATIONS_COMPONENTS); // TODO LUPO fix comparator // products = SortUtil.sortMapUsingComparator(products, new EntityNumberComparator()); for (Entry<Long, BigDecimal> neededProductQuantity : neededProductQuantities.entrySet()) { Entity product = productQuantitiesService.getProduct(neededProductQuantity.getKey()); table.addCell(new Phrase(product.getField(L_NUMBER).toString(), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(product.getField(L_NAME).toString(), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(new Phrase(numberService.format(neededProductQuantity.getValue()), FontUtils.getDejavuRegular7Dark())); BigDecimal available = BigDecimal.ZERO; for (Entity simpleMaterialBalanceLocationComponent : simpleMaterialBalanceLocationComponents) { available = available.add(materialFlowService.calculateShouldBeInLocation( simpleMaterialBalanceLocationComponent.getBelongsToField(L_LOCATION).getId(), product.getId(), (Date) simpleMaterialBalance.getField(L_DATE))); } table.addCell(new Phrase(numberService.format(available), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase( numberService.format( available.subtract(neededProductQuantity.getValue(), numberService.getMathContext())), FontUtils.getDejavuBold7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(new Phrase(product.getField(L_UNIT).toString(), FontUtils.getDejavuRegular7Dark())); } document.add(table); }
From source file:com.qcadoo.mes.technologies.print.TechnologiesTechnologyDetailsPdfView.java
License:Open Source License
@Override protected final String addContent(final Document document, final Map<String, Object> model, final Locale locale, final PdfWriter writer) throws DocumentException, IOException { checkState(model.get("id") != null, "Unable to generate report for unsaved technology! (missing id)"); String documentTitle = translationService .translate("technologies.technologiesTechnologyDetails.report.title", locale); String documentAuthor = translationService.translate("qcadooReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, new Date()); DataDefinition technologyDD = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY); Entity technology = technologyDD.get(valueOf(model.get("id").toString())); Map<String, String> panelTableValues = newLinkedHashMap(); panelTableValues.put(TechnologyFields.NAME, technology.getStringField(TechnologyFields.NAME)); panelTableValues.put(TechnologyFields.NUMBER, technology.getStringField(TechnologyFields.NUMBER)); panelTableValues.put(TechnologyFields.PRODUCT, technology.getBelongsToField(TechnologyFields.PRODUCT).getStringField(ProductFields.NAME)); panelTableValues.put("default", technology.getBooleanField(TechnologyFields.MASTER) ? translationService.translate("qcadooView.true", locale) : translationService.translate("qcadooView.false", locale)); panelTableValues.put(TechnologyFields.DESCRIPTION, technology.getStringField(TechnologyFields.DESCRIPTION)); PdfPTable panelTable = pdfHelper.createPanelTable(2); for (Map.Entry<String, String> panelEntry : panelTableValues.entrySet()) { pdfHelper.addTableCellAsOneColumnTable(panelTable, translationService.translate( "technologies.technologiesTechnologyDetails.report.panel.technology." + panelEntry.getKey(), locale), panelEntry.getValue()); }// www .j a v a 2 s .c o m panelTable.setSpacingAfter(20); panelTable.setSpacingBefore(20); document.add(panelTable); List<String> technologyDetailsTableHeader = new ArrayList<String>(); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.level", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.name", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.direction", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.productNumber", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.productName", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.quantity", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.unit", locale)); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); alignments.put(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.level", locale), HeaderAlignment.LEFT); alignments.put(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.name", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate( "technologies.technologiesTechnologyDetails.report.columnHeader.direction", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate( "technologies.technologiesTechnologyDetails.report.columnHeader.productNumber", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate( "technologies.technologiesTechnologyDetails.report.columnHeader.productName", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate( "technologies.technologiesTechnologyDetails.report.columnHeader.quantity", locale), HeaderAlignment.RIGHT); alignments.put(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.unit", locale), HeaderAlignment.LEFT); PdfPTable table = pdfHelper.createTableWithHeader(7, technologyDetailsTableHeader, false, alignments); EntityTree technologyTree = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); treeNumberingService.generateTreeNumbers(technologyTree); List<Entity> technologyOperationComponents = entityTreeUtilsService.getSortedEntities(technologyTree); for (Entity technologyOperationComponent : technologyOperationComponents) { String nodeNumber = technologyOperationComponent .getStringField(TechnologyOperationComponentFields.NODE_NUMBER); String operationName = technologyOperationComponent .getBelongsToField(TechnologyOperationComponentFields.OPERATION) .getStringField(OperationFields.NAME); List<Entity> operationProductComponents = newArrayList(); operationProductComponents.addAll(technologyOperationComponent .getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_IN_COMPONENTS)); operationProductComponents.addAll(technologyOperationComponent .getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS)); for (Entity operationProductComponent : operationProductComponents) { Entity product = operationProductComponent.getBelongsToField(L_PRODUCT); String productType = "technologies.technologiesTechnologyDetails.report.direction.out"; if (operationProductComponent.getDataDefinition().getName().equals("operationProductInComponent")) { productType = "technologies.technologiesTechnologyDetails.report.direction.in"; } table.addCell(new Phrase(nodeNumber, FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(operationName, FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(translationService.translate(productType, locale), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(product.getStringField(ProductFields.NUMBER), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(product.getStringField(ProductFields.NAME), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(new Phrase(numberService.format(operationProductComponent.getField(L_QUANTITY)), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell( new Phrase(product.getStringField(ProductFields.UNIT), FontUtils.getDejavuRegular7Dark())); } } document.add(table); return translationService.translate("technologies.technologiesTechnologyDetails.report.fileName", locale); }
From source file:com.qcadoo.mes.warehouseMinimalState.print.DocumentPdf.java
License:Open Source License
private PdfPTable createTable() { int[] headerWidths = Ints.toArray(getHeaderWidths()); Map<String, HeaderAlignment> headerValues = getHeaderValues(locale); PdfPTable warehouseTable = pdfHelper.createTableWithHeader(headerWidths.length, Lists.newArrayList(headerValues.keySet()), false, headerWidths, headerValues); warehouseTable.getDefaultCell().disableBorderSide(PdfPCell.RIGHT); warehouseTable.getDefaultCell().disableBorderSide(PdfPCell.LEFT); warehouseTable.setHeaderRows(1);//from ww w .j a v a2 s . c o m warehouseTable.setSpacingAfter(12.0f); return warehouseTable; }
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 www.j a va 2 s . com*/ }
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(// w ww. j a va 2s . c o m 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.OperationCommentOperation.java
License:Open Source License
public void print(Entity operationComponent, Document document, Locale locale) throws DocumentException { String commentContent = operationComponent.getStringField(TechnologyOperationComponentFields.COMMENT); if (commentContent == null) return;//from www . j ava2 s. co m PdfPTable table = pdfHelper.createPanelTable(1); table.getDefaultCell().setBackgroundColor(null); String commentLabel = translationService.translate("workPlans.workPlan.report.operation.comment", locale); pdfHelper.addTableCellAsOneColumnTable(table, commentLabel, commentContent); table.setSpacingAfter(18); table.setSpacingBefore(9); document.add(table); }
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()) {//from w w w . j a va 2 s . c om 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()) {/* ww w. ja v a2 s. c o m*/ 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())); }//from w ww . j av a 2 s . c o 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);//www . j av a2 s .c o m headerTable.setSpacingAfter(4.0f); headerTable.addCell(titleCell); headerTable.addCell(divisionCell); document.add(headerTable); }