List of usage examples for com.lowagie.text.pdf PdfPTable setSpacingAfter
public void setSpacingAfter(float spacing)
From source file:com.krawler.esp.servlets.ExportServlet.java
License:Open Source License
private static void addTitleSubtitle(Document d) throws DocumentException, JSONException { java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16)); fontBold.setColor(tColor);// w w w . j ava 2 s . c o m fontRegular.setColor(tColor); PdfPTable table = new PdfPTable(1); table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setWidthPercentage(100); table.setSpacingBefore(6); //Report Title PdfPCell cell = new PdfPCell(new Paragraph(config.getString("title"), fontBold)); cell.setBorder(0); cell.setBorderWidth(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); //Report Subtitle(s) String[] SubTitles = config.getString("subtitles").split("~");// '~' as separator for (int i = 0; i < SubTitles.length; i++) { cell = new PdfPCell(new Paragraph(SubTitles[i], fontSmallRegular)); cell.setBorder(0); cell.setBorderWidth(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } table.setSpacingAfter(6); d.add(table); //Separator line PdfPTable line = new PdfPTable(1); line.setWidthPercentage(100); PdfPCell cell1 = null; cell1 = new PdfPCell(new Paragraph("")); cell1.setBorder(PdfPCell.BOTTOM); line.addCell(cell1); d.add(line); }
From source file:com.krawler.spring.exportFunctionality.exportDAOImpl.java
License:Open Source License
public void addTitleSubtitle(Document d) throws ServiceException { try {/* ww w. j av a 2 s. c om*/ java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16)); PdfPTable table = new PdfPTable(1); table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setWidthPercentage(100); table.setSpacingBefore(6); //Report Title PdfPCell cell = new PdfPCell(new Paragraph( fontFamilySelector.process(config.getString("title"), FontContext.REPORT_TITLE, tColor)));//fontBold)); cell.setBorder(0); cell.setBorderWidth(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); //Report Subtitle(s) String[] SubTitles = config.getString("subtitles").split("~");// '~' as separator for (int i = 0; i < SubTitles.length; i++) { cell = new PdfPCell( new Paragraph(fontFamilySelector.process(SubTitles[i], FontContext.REPORT_TITLE, tColor))); cell.setBorder(0); cell.setBorderWidth(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } table.setSpacingAfter(6); d.add(table); //Separator line PdfPTable line = new PdfPTable(1); line.setWidthPercentage(100); PdfPCell cell1 = null; cell1 = new PdfPCell(new Paragraph("")); cell1.setBorder(PdfPCell.BOTTOM); line.addCell(cell1); d.add(line); } catch (Exception e) { throw ServiceException.FAILURE("exportDAOImpl.addTitleSubtitle", e); } }
From source file:com.krawler.spring.exportFunctionality.exportMPXDAOImpl.java
License:Open Source License
public void addTitleSubtitle(Document d) throws ServiceException { try {//ww w.ja v a 2 s . c o m java.awt.Color tColor = new Color(Integer.parseInt(config.getString("textColor"), 16)); // fontBold.setColor(tColor); // fontRegular.setColor(tColor); PdfPTable table = new PdfPTable(1); table.setHorizontalAlignment(Element.ALIGN_CENTER); table.setWidthPercentage(100); table.setSpacingBefore(6); //Report Title PdfPCell cell = new PdfPCell(new Paragraph( fontFamilySelector.process(config.getString("title"), FontContext.REPORT_TITLE, tColor))); cell.setBorder(0); cell.setBorderWidth(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); //Report Subtitle(s) String[] SubTitles = config.getString("subtitles").split("~");// '~' as separator for (int i = 0; i < SubTitles.length; i++) { cell = new PdfPCell(new Paragraph( (new Phrase(fontFamilySelector.process(SubTitles[i], FontContext.FOOTER_NOTE))))); cell.setBorder(0); cell.setBorderWidth(0); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); } table.setSpacingAfter(6); d.add(table); //Separator line PdfPTable line = new PdfPTable(1); line.setWidthPercentage(100); PdfPCell cell1 = null; cell1 = new PdfPCell(new Paragraph("")); cell1.setBorder(PdfPCell.BOTTOM); line.addCell(cell1); d.add(line); } catch (Exception e) { throw ServiceException.FAILURE("exportDAOImpl.addTitleSubtitle", e); } }
From source file:com.qcadoo.mes.costCalculation.print.CostCalculationPdfService.java
License:Open Source License
@Override protected void buildPdfContent(final Document document, final Entity entity, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("costCalculation.costCalculationDetails.report.title", locale);//ww w . j a v a 2 s .c om String documentAuthor = translationService.translate("qcadooReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, new Date()); DataDefinition dataDefCostCalculation = dataDefinitionService .get(CostCalculationConstants.PLUGIN_IDENTIFIER, CostCalculationConstants.MODEL_COST_CALCULATION); Entity costCalculation = dataDefCostCalculation.find("where id = " + entity.getId().toString()) .uniqueResult(); PdfPTable leftPanelColumn = addLeftPanelToReport(costCalculation, locale); PdfPTable rightPanelColumn = addRightPanelToReport(costCalculation, locale); PdfPTable panelTable = pdfHelper.createPanelTable(2); panelTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP); panelTable.addCell(leftPanelColumn); panelTable.addCell(rightPanelColumn); panelTable.setSpacingAfter(20); panelTable.setSpacingBefore(20); panelTable.setTableEvent(null); panelTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); document.add(panelTable); document.add(new Paragraph( translationService.translate("costCalculation.costCalculationDetails.report.paragraph", locale), FontUtils.getDejavuBold11Dark())); PdfPTable materialsTable = addMaterialsTable(costCalculation, locale); document.add(materialsTable); document.add(Chunk.NEWLINE); document.add(new Paragraph( translationService.translate("costCalculation.costCalculationDetails.report.paragraph2", locale), FontUtils.getDejavuBold11Dark())); CalculateOperationCostMode calculateOperationCostMode = CalculateOperationCostMode .parseString(costCalculation.getStringField(CostCalculationFields.CALCULATE_OPERATION_COSTS_MODE)); if (CalculateOperationCostMode.HOURLY.equals(calculateOperationCostMode)) { document.add(addHourlyCostsTable(costCalculation, locale)); } else if (CalculateOperationCostMode.PIECEWORK.equals(calculateOperationCostMode)) { document.add(addTableAboutPieceworkCost(costCalculation, locale)); } else { throw new IllegalStateException("Unsupported CalculateOperationCostMode"); } printMaterialAndOperationNorms(document, costCalculation, locale); }
From source file:com.qcadoo.mes.deviationCausesReporting.print.DeviationsProtocolPdf.java
License:Open Source License
private final Function<Collection<DeviationSummary>, PdfPTable> getSummariesToTableConverter( final Locale locale) { return new Function<Collection<DeviationSummary>, PdfPTable>() { @Override/* w w w .ja v a2s . c om*/ public PdfPTable apply(final Collection<DeviationSummary> deviationSummaries) { PdfPTable table = pdfHelper.createTableWithHeader(5, translate(SUMMARIES_TABLE_HEADERS, locale), true, new int[] { 10, 20, 45, 45, 60 }); table.setSpacingAfter(7.0f); int rowNumber = 1; for (DeviationSummary deviationSummary : deviationSummaries) { table.addCell(Phrases.tableContent(rowNumber++ + ".")); table.addCell( Phrases.tableContent(deviationSummary.getDate().toString(DateUtils.L_DATE_FORMAT))); table.addCell(Phrases.tableContent(deviationSummary.getOrderNumber())); table.addCell(Phrases.tableContent(deviationSummary.getProductNumber())); table.addCell(Phrases.tableContent(deviationSummary.getComment())); } return table; } }; }
From source file:com.qcadoo.mes.materialFlow.print.pdf.MaterialFlowPdfService.java
License:Open Source License
@Override protected void buildPdfContent(final Document document, final Entity materialsInLocation, final Locale locale) throws DocumentException { Map<Entity, BigDecimal> reportData = materialFlowService .calculateMaterialQuantitiesInLocation(materialsInLocation); String documenTitle = translationService.translate("materialFlow.materialFlow.report.title", locale); String documentAuthor = translationService.translate("qcadooReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documenTitle, documentAuthor, (Date) materialsInLocation.getField(TIME), materialsInLocation.getStringField(WORKER)); PdfPTable panelTable = pdfHelper.createPanelTable(2); pdfHelper.addTableCellAsOneColumnTable(panelTable, translationService.translate("materialFlow.materialFlow.report.panel.materialFlowForDate", locale), ((Date) materialsInLocation.getField(MATERIAL_FLOW_FOR_DATE)).toString()); pdfHelper.addTableCellAsOneColumnTable(panelTable, translationService.translate("materialFlow.materialFlow.report.panel.time", locale), ((Date) materialsInLocation.getField(TIME)).toString()); List<Entity> materialsInLocationComponents = materialsInLocation .getHasManyField(MATERIALS_IN_LOCATION_COMPONENTS); List<String> names = new ArrayList<String>(); for (Entity materialsInLocationComponent : materialsInLocationComponents) { Entity location = (Entity) materialsInLocationComponent.getField(LOCATION); names.add(location.getField(NUMBER).toString()); }// w w w. java 2 s . c o m pdfHelper.addTableCellAsOneColumnTable(panelTable, translationService.translate("materialFlow.materialFlow.report.panel.locations", locale), names); pdfHelper.addTableCellAsOneColumnTable(panelTable, "", ""); panelTable.setSpacingBefore(20); panelTable.setSpacingAfter(20); document.add(panelTable); List<String> tableHeader = new ArrayList<String>(); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); tableHeader .add(translationService.translate("materialFlow.materialFlow.report.columnHeader.number", locale)); tableHeader.add(translationService.translate("materialFlow.materialFlow.report.columnHeader.name", locale)); tableHeader.add( translationService.translate("materialFlow.materialFlow.report.columnHeader.quantity", locale)); tableHeader.add(translationService.translate("materialFlow.materialFlow.report.columnHeader.unit", locale)); alignments.put(translationService.translate("materialFlow.materialFlow.report.columnHeader.number", locale), HeaderAlignment.LEFT); alignments.put(translationService.translate("materialFlow.materialFlow.report.columnHeader.name", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate("materialFlow.materialFlow.report.columnHeader.quantity", locale), HeaderAlignment.RIGHT); alignments.put(translationService.translate("materialFlow.materialFlow.report.columnHeader.unit", locale), HeaderAlignment.LEFT); PdfPTable table = pdfHelper.createTableWithHeader(4, tableHeader, false, alignments); for (Map.Entry<Entity, BigDecimal> data : reportData.entrySet()) { table.addCell(new Phrase(data.getKey().getStringField(NUMBER), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(data.getKey().getStringField(NAME), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(new Phrase(numberService.format(data.getValue()), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(new Phrase(data.getKey().getStringField(UNIT), FontUtils.getDejavuRegular7Dark())); } document.add(table); }
From source file:com.qcadoo.mes.materialRequirements.print.pdf.MaterialRequirementPdfService.java
License:Open Source License
private void addPanel(final Document document, final Entity materialRequirement, final Locale locale) throws DocumentException { PdfPTable panelTable = pdfHelper.createPanelTable(2); pdfHelper.addTableCellAsOneColumnTable( panelTable, translationService .translate("materialRequirements.materialRequirement.report.panel.number", locale), materialRequirement.getStringField(MaterialRequirementFields.NUMBER)); pdfHelper.addTableCellAsOneColumnTable(panelTable, translationService.translate("materialRequirements.materialRequirement.report.panel.name", locale), StringUtils.isEmpty(materialRequirement.getStringField(MaterialRequirementFields.NAME)) ? "" : materialRequirement.getStringField(MaterialRequirementFields.NAME)); pdfHelper.addTableCellAsOneColumnTable(panelTable, translationService.translate("materialRequirements.materialRequirement.report.panel.mrpAlgorithm", locale),/*from w w w .ja va 2s.c o m*/ translationService.translate( "materialRequirements.materialRequirement.mrpAlgorithm.value." + materialRequirement.getStringField(MaterialRequirementFields.MRP_ALGORITHM), locale)); pdfHelper.addTableCellAsOneColumnTable(panelTable, "", ""); panelTable.setSpacingAfter(20); panelTable.setSpacingBefore(20); document.add(panelTable); }
From source file:com.qcadoo.mes.orders.print.OrderReportPdf.java
License:Open Source License
private void addHeaderTable(Document document, Entity orderEntity, Locale locale) throws DocumentException { PdfPTable table = pdfHelper.createPanelTable(3); List<HeaderPair> headerValues = getDocumentHeaderTableContent(orderEntity, locale); for (HeaderPair pair : headerValues) { if (pair.getValue() != null && !pair.getValue().isEmpty()) { pdfHelper.addTableCellAsOneColumnTable(table, pair.getLabel(), pair.getValue()); } else {//from w w w . j av a 2 s . co m pdfHelper.addTableCellAsOneColumnTable(table, StringUtils.EMPTY, StringUtils.EMPTY); } } table.setSpacingAfter(20); document.add(table); }
From source file:com.qcadoo.mes.orders.print.OrderReportPdf.java
License:Open Source License
private void addTableToDocument(Document document, Entity orderEntity, Locale locale, String headerKey, Map<String, String> values) throws DocumentException { document.add(//from w ww.j a v a2 s . c o m new Paragraph(translationService.translate(headerKey, locale), FontUtils.getDejavuBold10Dark())); Map<String, HeaderAlignment> headerValues = Maps.newLinkedHashMap(); for (String key : values.keySet()) { headerValues.put(translationService.translate(String.format(L_TRANSLATION_PATH, key), locale), HeaderAlignment.LEFT); } PdfPTable table = pdfHelper.createTableWithHeader(values.size(), Lists.newArrayList(headerValues.keySet()), false, headerValues); table.getDefaultCell().disableBorderSide(PdfPCell.RIGHT); table.getDefaultCell().disableBorderSide(PdfPCell.LEFT); table.setHeaderRows(1); for (String value : values.values()) { table.addCell(createCell(value, Element.ALIGN_LEFT)); } table.setSpacingAfter(20); document.add(table); }
From source file:com.qcadoo.mes.productionCounting.print.ProductionBalancePdfService.java
License:Open Source License
@Override protected void buildPdfContent(final Document document, final Entity productionBalance, final Locale locale) throws DocumentException { String documentTitle = translationService.translate("productionCounting.productionBalance.report.title", locale);/*from ww w. ja va2s . c om*/ String documentAuthor = translationService.translate("qcadooReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, productionBalance.getDateField(ProductionBalanceFields.DATE)); PdfPTable leftPanel = createLeftPanel(productionBalance, locale); PdfPTable rightPanel = createRightPanel(productionBalance, locale); PdfPTable panelTable = pdfHelper.createPanelTable(2); panelTable.addCell(leftPanel); panelTable.addCell(rightPanel); panelTable.setSpacingAfter(20); panelTable.setSpacingBefore(20); document.add(panelTable); Entity order = productionBalance.getBelongsToField(ProductionBalanceFields.ORDER); if (order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_IN_PRODUCT)) { addInputProductsBalance(document, productionBalance, locale); } if (order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_OUT_PRODUCT)) { addOutputProductsBalance(document, productionBalance, locale); } String calculateOperationCostMode = productionBalance .getStringField(ProductionBalanceFields.CALCULATE_OPERATION_COST_MODE); if (productionCountingService.isCalculateOperationCostModeHourly(calculateOperationCostMode)) { if (productionCountingService.isTypeOfProductionRecordingForEach( order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING))) { addMachineTimeBalance(document, productionBalance, locale); addLaborTimeBalance(document, productionBalance, locale); } else { addTimeBalanceAsPanel(document, productionBalance, locale); } } else if (productionCountingService.isCalculateOperationCostModePiecework(calculateOperationCostMode)) { addPieceworkBalance(document, productionBalance, locale); } }