List of usage examples for com.lowagie.text Chunk Chunk
public Chunk(DrawInterface separator, float tabPosition)
From source file:org.displaytag.export.PdfView.java
License:Artistic License
/** * Returns a formatted cell for the given value. * @param value cell value/*from w ww. jav a2 s. co m*/ * @return Cell * @throws BadElementException errors while generating content */ private Cell getCell(String value) throws BadElementException { Cell cell = new Cell(new Chunk(StringUtils.trimToEmpty(value), smallFont)); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setLeading(8); return cell; }
From source file:org.displaytag.render.ItextTableWriter.java
License:Artistic License
/** * Writes the table caption according to a set style. * @param model The table model containing the caption. * @throws DocumentException If an error occurrs while decorating the caption. */// w ww . ja v a 2s.c o m private void decorateCaption(TableModel model) throws DocumentException { Paragraph caption = new Paragraph(new Chunk(model.getCaption(), this.getCaptionFont())); caption.setAlignment(this.getCaptionHorizontalAlignment()); this.document.add(caption); }
From source file:org.displaytag.render.ItextTableWriter.java
License:Artistic License
/** * @see org.displaytag.render.TableWriterTemplate#writePostBodyFooter(org.displaytag.model.TableModel) * @throws DocumentException if an error occurs while writing post-body footer. *//*from w ww .j a v a 2 s .c om*/ protected void writePostBodyFooter(TableModel model) throws DocumentException { Chunk cellContent = new Chunk(model.getFooter(), this.getFooterFont()); this.setFooterFontStyle(cellContent); Cell cell = new Cell(cellContent); cell.setLeading(8); cell.setBackgroundColor(this.getFooterBackgroundColor()); cell.setHorizontalAlignment(this.getFooterHorizontalAlignment()); cell.setColspan(model.getNumberOfColumns()); table.addCell(cell); }
From source file:org.displaytag.render.ItextTableWriter.java
License:Artistic License
/** * Returns a formatted cell for the given value. * @param value cell value/*ww w .ja v a2 s .c o m*/ * @return Cell * @throws BadElementException if errors occurs while generating content. */ private Cell getCell(Object value) throws BadElementException { Cell cell = new Cell(new Chunk(StringUtils.trimToEmpty(ObjectUtils.toString(value)), this.defaultFont)); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setLeading(8); return cell; }
From source file:org.displaytag.render.ItextTableWriter.java
License:Artistic License
/** * Obtain a header cell./*from ww w . j av a2 s.c o m*/ * @param value Cell content. * @return A header cell with the given content. * @throws BadElementException if errors occurs while generating content. */ private Cell getHeaderCell(String value) throws BadElementException { Chunk cellContent = new Chunk(value, this.getHeaderFont()); setHeaderFontStyle(cellContent); Cell cell = new Cell(cellContent); cell.setLeading(8); cell.setHeader(true); cell.setHorizontalAlignment(this.getHeaderHorizontalAlignment()); cell.setBackgroundColor(this.getHeaderBackgroundColor()); return cell; }
From source file:org.egov.infra.web.displaytag.export.EGovPdfView.java
License:Open Source License
protected void generateCaption() throws BadElementException { final Paragraph caption = new Paragraph( new Chunk(removeHtmlTagsAndSpaces(this.model.getCaption()), this.getCaptionFont())); caption.setAlignment(this.getCaptionHorizontalAlignment()); this.tableCaption = caption; }
From source file:org.egov.infra.web.displaytag.export.EGovPdfView.java
License:Open Source License
/** * Returns a formatted cell for the given value. * @param value cell value//from w w w .ja v a 2 s . com * @return Cell * @throws BadElementException errors while generating content */ private Cell getCell(String value) throws BadElementException { value = removeHtmlTagsAndSpaces(value); final Cell cell = new Cell(new Chunk(StringUtils.trimToEmpty(value), this.smallFont)); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setLeading(8); return cell; }
From source file:org.egov.works.web.actions.contractorBill.ContractorBillPDFGenerator.java
License:Open Source License
protected void createCertificate() throws DocumentException { final Paragraph headerTextPara = new Paragraph(new Chunk(pdfLabel.get("contractorbill.pdf.contractorbill"), new Font(Font.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLD))); headerTextPara.setAlignment(Element.ALIGN_CENTER); document.add(headerTextPara);/* w ww .ja v a 2 s . co m*/ final Paragraph certificateheaderTextPara = new Paragraph(new Chunk( pdfLabel.get("contractorbill.pdf.certificate"), new Font(Font.COURIER, LARGE_FONT, Font.BOLD))); certificateheaderTextPara.setAlignment(Element.ALIGN_CENTER); document.add(certificateheaderTextPara); document.add(spacer()); document.add(spacer()); document.add(makePara(pdfLabel.get("contractorbill.pdf.certificatecontent1"))); document.add(spacer()); document.add(spacer()); document.add(rightPara( pdfLabel.get("contractorbill.pdf.juniorengineer") + "\t \t\t \t \t \t\t \t\t \t \t \t \t")); document.add(spacer()); document.add(rightPara(pdfLabel.get(dateLabel) + "\t \t \t \t\t \t\t \t \t \t \t\t \t\t \t \t \t \t\t \t\t" + "\t \t\t \t\t \t \t \t \t\t \t\t\t\t \t\t \t\t")); document.add(spacer()); document.add(makePara(pdfLabel.get("contractorbill.pdf.certificatecontent2"))); document.add(spacer()); document.add(spacer()); document.add(rightPara(pdfLabel.get("contractorbill.pdf.exeasstengineer") + "\t \t")); document.add(spacer()); document.add(rightPara(pdfLabel.get(dateLabel) + "\t \t \t \t\t \t\t \t \t \t \t\t \t\t \t \t \t \t\t \t\t" + "\t \t \t \t\t \t\t \t \t \t \t\t \t\t \t \t \t \t\t \t\t\t \t \t\t\t \t\t \t \t \t \t\t \t\t \t \t \t \t\t \t\t \t \t \t \t\t \t\t")); document.add(spacer()); document.add(makePara(pdfLabel.get("contractorbill.pdf.certificatecontent3"))); document.add(spacer()); document.add(makePara(pdfLabel.get("contractorbill.pdf.certificatecontent4"))); document.add(spacer()); document.add(makePara(pdfLabel.get("contractorbill.pdf.certificatecontent5"))); document.add(spacer()); document.add(spacer()); document.add(makePara(pdfLabel.get("contractorbill.pdf.certificatecontent6"))); document.add(spacer()); document.add(spacer()); document.add(makePara(pdfLabel.get("contractorbill.pdf.juniorengineer") + "\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t " + tab2 + tab2 + "\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t\t \t \t \t \t \t \t \t \t \t \t" + pdfLabel.get("contractorbill.pdf.exeasstengineer"))); document.add(spacer()); document.add(makePara(pdfLabel.get(dateLabel) + "\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t" + tab2 + tab2 + "\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t" + "\t \t \t \t \t \t \t \t " + pdfLabel.get(dateLabel))); }
From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java
License:Open Source License
public void generatePDF() { try {/*w w w. j a v a 2 s .co m*/ final Paragraph headerTextPara = new Paragraph( new Chunk(headerText, new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD))); String projectCode; final String oldEstNo = ""; HeaderFooter hf; headerTextPara.setAlignment(Element.ALIGN_CENTER); document.add(headerTextPara); document.add(makePara("Executing Department:" + estimate.getExecutingDepartment().getName(), Element.ALIGN_LEFT)); if (estimate.getUserDepartment() != null) document.add( makePara("User Department:" + estimate.getUserDepartment().getName(), Element.ALIGN_LEFT)); final CFinancialYear estimateFinancialYear = estimate.getMultiYearEstimates().get(0).getFinancialYear(); addZoneYearHeader(estimate, estimateFinancialYear); document.add(makePara("Name of Work: " + estimate.getName(), Element.ALIGN_LEFT)); document.add(makePara("Description: " + estimate.getDescription(), Element.ALIGN_LEFT)); if (estimate.getProjectCode() != null) { projectCode = "Project Code : " + estimate.getProjectCode().getCode(); document.add(makePara(projectCode, Element.ALIGN_LEFT)); hf = new HeaderFooter(new Phrase("\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t" + "\t \t \t \t \t\t \t \t \t \t\t \t \t \t \t\t \t \t " + "\t \t \t \t \t\t \t \t \t \t" + headerText.concat("\n") .concat("\t \t \t \t \t \t \t \t \t \t" + "\t \t \t \t \t\t \t \t \t \t\t \t \t \t \t\t \t \t " + "\t \t \t \t \t\t \t \t \t \t ABSTRACT ESTIMATE") .concat("\n\n").concat("Name of Work: " + estimate.getName()).concat("\n") .concat("Description: " + estimate.getDescription()).concat("\n") .concat("Estimate Number: " + estimate.getEstimateNumber()).concat(oldEstNo) .concat("\n").concat(projectCode)), false); } else hf = new HeaderFooter(new Phrase("\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t" + "\t \t \t \t \t\t \t \t \t \t\t \t \t \t \t\t \t \t " + "\t \t \t \t \t\t \t \t \t \t" + headerText.concat("\n") .concat("\t \t \t \t \t \t \t \t \t \t" + "\t \t \t \t \t\t \t \t \t \t\t \t \t \t \t\t \t \t " + "\t \t \t \t \t\t \t \t \t \t ABSTRACT ESTIMATE") .concat("\n\n").concat("Name of Work: " + estimate.getName()).concat("\n") .concat("Description: " + estimate.getDescription()).concat("\n") .concat("Estimate Number: " + estimate.getEstimateNumber()).concat(oldEstNo)), false); hf.disableBorderSide(Rectangle.TOP); hf.disableBorderSide(Rectangle.BOTTOM); hf.setLeft(Element.ALIGN_LEFT); document.setHeader(hf); final PdfPTable overheadsTable = createOverheadsTable(estimate); document.add(spacer()); document.add(overheadsTable); document.add(spacer()); final PdfPTable multiyearTable = createMultiYearTable(estimate); document.add(makePara("Year-wise Estimate")); document.add(spacer()); document.add(multiyearTable); document.add(spacer()); document.add(makePara("Estimate Created By: " + estimate.getCreatedBy().getName())); document.add(spacer()); document.add(spacer()); document.add(makePara("Checked By: ")); document.newPage(); addZoneYearHeaderWithOutEstimateNo(estimate, estimateFinancialYear); document.add(createActivitiesTable(estimate)); document.add(spacer()); final PdfPTable approvaldetailsTable = createApprovalDetailsTable(estimate); // TODO:Fixme - commented final out workflow history final details since ordering final of approval is final not // getting final listed properly /* * if (approvaldetailsTable.getRows().size() != 1) { document.add(makePara("Approval Details")); * document.add(spacer()); document.add(approvaldetailsTable); } */ final String appropriationNumber = abstractEstimateService .getLatestEstimateAppropriationNumber(estimate); if (isSkipBudgetCheck()) { final PdfPTable depositWorksAppropriationTable = createDepositAppropriationTable(estimate, appropriationNumber); if (depositWorksAppropriationTable.getRows().size() != 1) if (appropriationNumber != null) { document.newPage(); document.add(spacer()); document.add(makePara("Deposit Code Appropriation Details")); document.add(spacer()); document.add(depositWorksAppropriationTable); } } else { final PdfPTable BudgetaryAppropriationTable = createBudgetaryAppropriationTable(estimate, appropriationNumber); final String estimateNumber = estimate.getEstimateNumber(); if (BudgetaryAppropriationTable.getRows().size() != 1) if (!getBudgetDetailUsage(estimateNumber).isEmpty() && appropriationNumber != null) { document.newPage(); document.add(spacer()); document.add(makePara("Budgetary Appropriation")); document.add(spacer()); document.add(BudgetaryAppropriationTable); } } document.newPage(); document.add(spacer()); document.add(makePara( "EXECUTIVE ENGINEER'S OFFICE, ZONE.......................................................................", Element.ALIGN_LEFT)); document.add(spacer()); document.add(makePara( "Est No. Unit: Dept.", Element.ALIGN_LEFT)); document.add(spacer()); final Paragraph budgetheadTextPara = new Paragraph( new Chunk("BUDGET HEAD", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD))); budgetheadTextPara.setAlignment(Element.ALIGN_CENTER); document.add(budgetheadTextPara); document.add(spacer()); document.add(makePara("____________________________________________________________________________", Element.ALIGN_LEFT)); document.add(makePara("Rs. ", Element.ALIGN_LEFT)); document.add(makePara("____________________________________________________________________________", Element.ALIGN_LEFT)); document.add(makePara("Works: ", Element.ALIGN_LEFT)); document.add(spacer()); document.add(spacer()); final Paragraph memoTextPara = new Paragraph( new Chunk("MEMO", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD))); memoTextPara.setAlignment(Element.ALIGN_CENTER); document.add(memoTextPara); document.add(makePara("Budget Grant ", Element.ALIGN_LEFT)); document.add(makePara("Amount Appropriated:__________________________________________________________", Element.ALIGN_LEFT)); document.add(makePara("Balance on Hand: ", Element.ALIGN_LEFT)); document.add( makePara("Amount of this estimate_________________________________________________________", Element.ALIGN_LEFT)); document.add(makePara("Balance forward_______________________________________________________________", Element.ALIGN_LEFT)); document.add( makePara("Submitted for favour of sanction ", Element.ALIGN_LEFT)); document.add(spacer()); document.add(spacer()); document.add( makePara("A.E.E.Unit " + space1 + "\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t" + "Exe.Eng.Zone.....................", Element.ALIGN_LEFT)); document.add(spacer()); document.add(makePara("Sanctioned", Element.ALIGN_CENTER)); document.add(spacer()); document.add(spacer()); document.add(makePara("DATE:" + space1 + "\t \t \t \t \t \t \t \t \t \t \t \t\t \t \t \t \t \t \t \t \t \t \t \t" + "Asst.Commissioner Zone...............", Element.ALIGN_LEFT)); document.add(spacer()); document.add(makePara( space1 + "\t \t \t \t \t \t \t \t \t \t \t \t\t \t \t \t \t \t \t \t \t \t \t \t" + "APPROPRIATION No.", Element.ALIGN_LEFT)); document.add(makePara(space1 + "\t \t \t \t \t \t \t \t \t \t \t \t" + "\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t" + "Date:", Element.ALIGN_LEFT)); // WF for signature ----- if (approvaldetailsTable.getRows().size() != 1) if (shouldShowApprovalNumber) { document.resetHeader(); document.newPage(); document.add( makePara("\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t" + "\t \t \t \t \t\t \t \t \t \t\t \t \t \t \t\t \t \t " + "\t \t \t \t \t\t \t \t \t \t" + headerText.concat("\n").concat("\t \t \t \t \t \t \t \t \t \t" + "\t \t \t \t \t\t \t \t \t \t\t \t \t \t \t\t \t \t " + "\t \t \t \t \t\t \t \t \t \t ABSTRACT ESTIMATE") .concat("\n\n"))); document.add( makePara( "File Current Number :" + space1 + "\t \t \t \t \t \t \t \t \t \t \t \t \t " + "Date: \t \t", Element.ALIGN_LEFT)); document.add(makePara(space1 + "\t \t \t \t \t \t \t \t \t \t \t \t\t \t \t \t \t \t \t \t \t \t \t " + "Department : ", Element.ALIGN_LEFT)); document.add(spacer()); final Paragraph headingPara1 = new Paragraph( new Chunk("NOTE FOR ADMINISTRATIVE SANCTION AS PER RULE 78 OF ", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD))); headingPara1.setAlignment(Element.ALIGN_CENTER); document.add(headingPara1); final Paragraph headingPara2 = new Paragraph( new Chunk("MCMC ACT 1919 ", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD))); headingPara2.setAlignment(Element.ALIGN_CENTER); document.add(headingPara2); document.add(spacer()); final PdfPTable estimateDetailsTable1 = createEstimateDetailsTable1(estimate); document.add(estimateDetailsTable1); final PdfPTable budgetDetailsTableFourCols = createBudgetDetailsForEstimateTable(estimate); document.add(budgetDetailsTableFourCols); final PdfPTable estimateDetailsTable2 = createBalanceAmtCalculationTable(estimate); document.add(estimateDetailsTable2); document.add(spacer()); final Paragraph endTextPara = new Paragraph( new Chunk("** END **", new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD))); endTextPara.setAlignment(Element.ALIGN_CENTER); document.add(endTextPara); } document.close(); } catch (final DocumentException e) { throw new ApplicationRuntimeException("estimate.pdf.error", e); } }
From source file:org.egov.works.web.actions.measurementbook.MeasurementBookPDFGenerator.java
License:Open Source License
public void generatePDF() { final String headerText = pdfLabel.get("mbpdf.header"); try {//from www . j av a 2 s.c om // start header Part final Paragraph headerTextPara = new Paragraph( new Chunk(headerText, new Font(Font.UNDEFINED, LARGE_FONT, Font.BOLD))); headerTextPara.setAlignment(Element.ALIGN_CENTER); document.add(headerTextPara); document.add(spacer()); if (mbHeader != null) { String toPageno = ""; if (mbHeader.getToPageNo() == null || mbHeader.getToPageNo().intValue() == 0) toPageno = mbHeader.getFromPageNo().toString(); else toPageno = mbHeader.getToPageNo().toString(); document.add(makeParaWithFont(8, " \t \t \t \t \t " + pdfLabel.get("mbpdf.refno") + mbHeader.getMbRefNo() + " \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t " + pdfLabel.get("mbpdf.pageno") + " : " + mbHeader.getFromPageNo() + " to " + toPageno + " \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t " + pdfLabel.get("mbpdf.date") + sdf.format(mbHeader.getMbDate()), Element.ALIGN_LEFT)); } document.add(spacer()); includeRevisionTypeColumn = false; // /Find if revision type Non tendered and Lump sum items are there areNTOrLSItemsPresent(mbHeader); // creating label row PdfPTable mbTable = createMbTable(); if (mbHeader != null) mbTable = createMbData(mbTable, mbHeader); document.add(mbTable); document.add(spacer()); document.newPage(); // approval details table PdfPTable approvaldetailsTable = null; if (mbHeader != null) approvaldetailsTable = createApprovalDetailsTable(mbHeader); document.add(makePara(8, pdfLabel.get("mbpdf.approvaldetails"))); document.add(spacer()); document.add(approvaldetailsTable); document.close(); } catch (final DocumentException e) { throw new ApplicationRuntimeException(MEASUREMENTBOOK_PDF_ERROR, e); } }