List of usage examples for com.lowagie.text Document add
public boolean add(Element element) throws DocumentException
Element
to the Document
. From source file:com.qcadoo.mes.warehouseMinimalState.print.DocumentPdf.java
License:Open Source License
private void addWarehouseTable(Document document, Entity warehouse) throws DocumentException { String subtitle = translationService.translate("warehouseMinimalState.report.subtitle", locale, warehouse.getStringField(LocationFields.NUMBER), warehouse.getStringField(LocationFields.NAME)); PdfPTable warehouseTable = createTable(); List<Entity> stocks = warehouseMinimalStateHelper.getWarehouseStockWithTooSmallMinState(warehouse); Map<Long, Entity> stocksByProduct = stocks.stream() .collect(Collectors.toMap(res -> res.getBelongsToField("product").getId(), (res) -> res)); Collection<Entity> minimumStates = warehouseToMinimumStateMap.get(warehouse.getId()); minimumStates = minimumStates.stream() .sorted((ms1, ms2) -> ms1.getBelongsToField("product").getStringField(ProductFields.NUMBER) .compareToIgnoreCase(ms2.getBelongsToField("product").getStringField(ProductFields.NUMBER))) .collect(Collectors.toList()); boolean rowsWereAdded = false; for (Entity minimumState : minimumStates) { rowsWereAdded |= addRow(minimumState, stocksByProduct, warehouseTable); }/*from w w w . j av a2 s . c om*/ if (rowsWereAdded) { document.add(new Paragraph(subtitle, FontUtils.getDejavuBold11Light())); document.add(warehouseTable); } }
From source file:com.qcadoo.mes.workPlans.pdf.document.component.OperationSection.java
License:Open Source License
public void print(PdfWriter pdfWriter, GroupingContainer groupingContainer, Document document, Locale locale) throws DocumentException { if (notPrintOperationAtFirstPage()) { document.newPage();/*from ww w . j a v a 2 s . c o m*/ } ListMultimap<String, OrderOperationComponent> titleToOperationComponent = groupingContainer .getTitleToOperationComponent(); for (String title : titleToOperationComponent.keySet()) { operationSectionHeader.print(document, title); int count = 0; for (OrderOperationComponent orderOperationComponent : groupingContainer.getTitleToOperationComponent() .get(title)) { count++; operationOrderSection.print(pdfWriter, groupingContainer, orderOperationComponent.getOrder(), orderOperationComponent.getOperationComponent(), document, locale); if (count != titleToOperationComponent.get(title).size()) { if (notPrintOperationAtFirstPage()) { document.add(Chunk.NEXTPAGE); } } } } }
From source file:com.qcadoo.mes.workPlans.pdf.document.component.OperationSectionHeader.java
License:Open Source License
public void print(Document document, String title) throws DocumentException { document.add(titleParagraph(title)); }
From source file:com.qcadoo.mes.workPlans.pdf.document.operation.component.OperationAdditionalFields.java
License:Open Source License
public void print(Entity operationComponent, Document document, Locale locale) throws DocumentException { Optional<String> imageUrlInWorkPlan = getImageUrlInWorkPlan(operationComponent); if (!imageUrlInWorkPlan.isPresent()) return;/*from ww w. j a va 2 s.c om*/ document.add(new Paragraph(title(locale), FontUtils.getDejavuBold10Dark())); pdfHelper.addImage(document, imageUrlInWorkPlan.get()); document.add(Chunk.NEXTPAGE); }
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(/*from w w w. j a va 2 s . 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;//w ww .j a v a 2s . c o 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.OperationOrderHeader.java
License:Open Source License
public void print(Entity order, GroupingContainer groupingContainer, Entity operationComponent, Document document, Locale locale) throws DocumentException { PdfPTable operationTable = pdfHelper.createPanelTable(3); operationOrderInfoOperation.print(operationComponent, operationTable, locale); if (groupingContainer.hasManyOrders() && isOrderInfoEnabled(operationComponent)) { operationOrderInfoHeader.print(order, operationTable, locale); }//from w ww. j a va 2s. com if (isWorkstationInfoEnabled(operationComponent)) { operationOrderInfoWorkstation.print(operationComponent, operationTable, locale); } operationTable.setSpacingAfter(18); operationTable.setSpacingBefore(9); document.add(operationTable); }
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 .jav a 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.OperationProductInTableHeader.java
License:Open Source License
public void print(Document document, Locale locale) throws DocumentException { document.add(paragraph(title(locale))); }
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 w w w . j a v a 2s . c om*/ 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); }