List of usage examples for com.lowagie.text.pdf PdfPTable setWidths
public void setWidths(int relativeWidths[]) throws DocumentException
From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java
License:Open Source License
private PdfPTable createBalanceAmtCalculationTable(final AbstractEstimate estimate) throws DocumentException { try {/*from www . j a va2 s . c o m*/ final PdfPTable estimateDetailsTable2 = new PdfPTable(2); estimateDetailsTable2.setWidthPercentage(75); estimateDetailsTable2.setWidths(new float[] { 0.6f, 1f }); BigDecimal budgetAvailable = BigDecimal.ZERO; BigDecimal totalUtilizedAmt; BigDecimal totalDepositAmt; BigDecimal balanceAvailable = BigDecimal.ZERO; final Accountdetailtype accountdetailtype = worksService.getAccountdetailtypeByName("DEPOSITCODE"); if (abstractEstimateAppropriationList != null && !abstractEstimateAppropriationList.isEmpty()) { final AbstractEstimateAppropriation latestAbstractEstimateAppropriation = abstractEstimateAppropriationList .get(abstractEstimateAppropriationList.size() - 1); if (latestAbstractEstimateAppropriation != null) if (estimate.getDepositCode() == null) { if (latestAbstractEstimateAppropriation.getBudgetUsage().getConsumedAmount() != 0) budgetAvailable = latestAbstractEstimateAppropriation.getBalanceAvailable(); } else if (latestAbstractEstimateAppropriation.getDepositWorksUsage().getConsumedAmount() .doubleValue() != 0) { totalDepositAmt = depositWorksUsageService.getTotalDepositWorksAmount( estimate.getDepositCode().getFund(), latestAbstractEstimateAppropriation.getAbstractEstimate().getFinancialDetails() .get(0).getCoa(), accountdetailtype, estimate.getDepositCode().getId(), latestAbstractEstimateAppropriation.getDepositWorksUsage().getAppropriationDate()); totalUtilizedAmt = depositWorksUsageService.getTotalUtilizedAmountForDepositWorks( latestAbstractEstimateAppropriation.getAbstractEstimate().getFinancialDetails() .get(0), latestAbstractEstimateAppropriation.getDepositWorksUsage().getCreatedDate()); if (totalUtilizedAmt == null) totalUtilizedAmt = BigDecimal.ZERO; balanceAvailable = BigDecimal .valueOf(totalDepositAmt.doubleValue() - totalUtilizedAmt.doubleValue()); } } if (estimate.getDepositCode() == null) addRow(estimateDetailsTable2, true, centerPara("Balance Amount Available"), centerPara(budgetAvailable == null ? "" : toCurrency(budgetAvailable.doubleValue()))); else addRow(estimateDetailsTable2, true, centerPara("Balance Amount Available"), centerPara(balanceAvailable == null ? "" : toCurrency(balanceAvailable.doubleValue()))); addRow(estimateDetailsTable2, true, centerPara("Reference"), centerPara(space1)); addRow(estimateDetailsTable2, true, centerPara("Any Other Remarks"), centerPara(space1 + "\n\n")); return estimateDetailsTable2; } catch (final Exception e) { throw new ApplicationRuntimeException( "Exception occured while estimate and budget details method 3" + e); } }
From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java
License:Open Source License
private PdfPTable createActivitiesTable(final AbstractEstimate estimate) throws DocumentException { final PdfPTable activitiesTable = new PdfPTable(7); activitiesTable.setWidthPercentage(100); activitiesTable.setWidths(new float[] { 0.5f, 1f, 3.1f, 1.2f, 0.8f, 1.1f, 1.5f }); addRow(activitiesTable, true, makePara("Sl No"), centerPara("Quantity"), centerPara("Description"), centerPara("Sch. No"), centerPara("Unit"), centerPara("Rate"), centerPara("Amount")); Collection<Activity> activities = estimate.getSORActivities(); int index = 1; for (final Activity activity : activities) { String estimateUom = ""; if (activity.getUom() == null) estimateUom = activity.getSchedule().getUom().getUom(); else/*from w ww .j a v a 2 s .c o m*/ estimateUom = activity.getUom().getUom(); addRow(activitiesTable, true, makePara(index++), rightPara(activity.getQuantity()), makePara(activity.getSchedule().getDescription()), centerPara(activity.getSchedule().getCode()), centerPara(estimateUom), rightPara(toCurrency(activity.getSORCurrentRate())), rightPara(toCurrency(activity.getAmount()))); } activities = estimate.getNonSORActivities(); for (final Activity activity : activities) addRow(activitiesTable, true, makePara(index++), rightPara(activity.getQuantity()), makePara(activity.getNonSor().getDescription()), centerPara(""), centerPara(activity.getNonSor().getUom().getUom()), rightPara(toCurrency(activity.getRate())), rightPara(toCurrency(activity.getAmount()))); addRow(activitiesTable, true, centerPara(""), centerPara(""), makePara(""), rightPara(""), centerPara(""), centerPara("TOTAL"), rightPara(toCurrency(estimate.getWorkValue()))); addRow(activitiesTable, true, centerPara(""), centerPara(""), makePara(""), rightPara(""), centerPara(""), centerPara("WORK VALUE"), rightPara(toCurrency(estimate.getWorkValueIncludingTaxes()))); return activitiesTable; }
From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java
License:Open Source License
private void addZoneYearHeader(final AbstractEstimate estimate, final CFinancialYear financialYear) throws DocumentException { document.add(spacer());//from w ww. ja v a 2 s .c om final PdfPTable headerTable = new PdfPTable(2); headerTable.setWidthPercentage(100); headerTable.setWidths(new float[] { 1f, 1f }); Paragraph financialYearPara = new Paragraph(); if (financialYear != null) financialYearPara = makePara("Budget Year: " + financialYear.getFinYearRange(), Element.ALIGN_RIGHT); addRow(headerTable, false, makePara("Estimate Number: " + estimate.getEstimateNumber(), Element.ALIGN_LEFT), financialYearPara); document.add(headerTable); if (estimate.getWard() != null && "Ward".equalsIgnoreCase(estimate.getWard().getBoundaryType().getName()) && estimate.getWard().getParent() != null && estimate.getWard().getParent().getName() != null) document.add(makePara("Ward: " + estimate.getWard().getName() + " / Zone: " + estimate.getWard().getParent().getName(), Element.ALIGN_RIGHT)); else if (estimate.getWard() != null && "Zone".equalsIgnoreCase(estimate.getWard().getBoundaryType().getName()) && estimate.getWard().getParent() != null && estimate.getWard().getParent().getName() != null) document.add(makePara("Zone: " + estimate.getWard().getName() + " / Region: " + estimate.getWard().getParent().getName(), Element.ALIGN_RIGHT)); else if (estimate.getWard() != null) document.add(makePara("Jurisdiction: " + estimate.getWard().getName() + "(" + estimate.getWard().getBoundaryType().getName() + ")", Element.ALIGN_RIGHT)); document.add(spacer()); }
From source file:org.egov.works.web.actions.estimate.EstimatePDFGenerator.java
License:Open Source License
private void addZoneYearHeaderWithOutEstimateNo(final AbstractEstimate estimate, final CFinancialYear financialYear) throws DocumentException { final PdfPTable headerTable = new PdfPTable(2); headerTable.setWidthPercentage(100); headerTable.setWidths(new float[] { 1f, 1f }); Paragraph financialYearPara = new Paragraph(); if (financialYear != null) financialYearPara = makePara("Budget Year: " + financialYear.getFinYearRange(), Element.ALIGN_RIGHT); addRow(headerTable, false, new Paragraph(), financialYearPara); document.add(headerTable);/*from w ww . j ava 2s . c o m*/ if (estimate.getWard() != null && "Ward".equalsIgnoreCase(estimate.getWard().getBoundaryType().getName()) && estimate.getWard().getParent() != null && estimate.getWard().getParent().getName() != null) document.add(makePara("Ward: " + estimate.getWard().getName() + " / Zone: " + estimate.getWard().getParent().getName(), Element.ALIGN_RIGHT)); else if (estimate.getWard() != null && "Zone".equalsIgnoreCase(estimate.getWard().getBoundaryType().getName()) && estimate.getWard().getParent() != null && estimate.getWard().getParent().getName() != null) document.add(makePara("Zone: " + estimate.getWard().getName() + " / Region: " + estimate.getWard().getParent().getName(), Element.ALIGN_RIGHT)); else if (estimate.getWard() != null) document.add(makePara("Jurisdiction: " + estimate.getWard().getName() + "(" + estimate.getWard().getBoundaryType().getName() + ")", Element.ALIGN_RIGHT)); document.add(spacer()); }
From source file:org.egov.works.web.actions.measurementbook.MeasurementBookPDFGenerator.java
License:Open Source License
private PdfPTable createApprovalDetailsTable(final MBHeader mbHeader) throws DocumentException { try {/*from w w w . ja v a 2 s. co m*/ final PdfPTable approvaldetailsTable = new PdfPTable(5); approvaldetailsTable.setWidthPercentage(100); approvaldetailsTable.setWidths(new float[] { 2f, 1f, 1f, 1.5f, 2f }); addRow(approvaldetailsTable, true, makePara(8, pdfLabel.get("mbpdf.aprvalstep")), centerPara(8, pdfLabel.get("mbpdf.name")), centerPara(8, pdfLabel.get("mbpdf.designation")), centerPara(8, pdfLabel.get("mbpdf.aprvdon")), centerPara(8, pdfLabel.get("mbpdf.remarks"))); List<StateHistory<Position>> history = null; String code = ""; if (mbHeader.getCurrentState() != null && mbHeader.getCurrentState().getHistory() != null) history = mbHeader.getStateHistory(); if (history != null) { Collections.reverse(history); for (final StateHistory<Position> ad : history) if (!ad.getValue().equals("NEW") && !ad.getValue().equals("END")) { String nextAction = ""; if (ad.getNextAction() != null) nextAction = ad.getNextAction(); Long positionId = null; String desgName = null; DeptDesig deptdesig = null; positionId = ad.getOwnerPosition().getId(); deptdesig = ad.getOwnerPosition().getDeptDesig(); desgName = deptdesig.getDesignation().getName(); final PersonalInformation emp = employeeService.getEmpForPositionAndDate( ad.getCreatedDate(), Integer.parseInt(positionId.toString())); code = ad.getValue(); final EgwStatus status = (EgwStatus) getPersistenceService() .find("from EgwStatus where moduletype=? and code=?", "MBHeader", code); String state = status.getDescription(); if (!nextAction.equalsIgnoreCase("")) state = status.getDescription() + " - " + nextAction; addRow(approvaldetailsTable, true, makePara(8, state), makePara(8, emp.getEmployeeName()), makePara(8, desgName), makePara(8, getDateInFormat(ad.getCreatedDate().toString())), rightPara(8, ad.getComments())); } } return approvaldetailsTable; } catch (final Exception e) { throw new DocumentException("Exception occured while getting approval details " + e); } }
From source file:org.egov.works.web.actions.measurementbook.MeasurementBookPDFGenerator.java
License:Open Source License
private PdfPTable createMbTable() throws DocumentException { PdfPTable mbTable; if (includeRevisionTypeColumn) { mbTable = new PdfPTable(12); mbTable.setWidths(new float[] { 1f, 1.5f, 4f, 1.4f, 1.9f, 1.6f, 1.4f, 1.8f, 1.9f, 1.9f, 1.9f, 1.6f }); } else {//from ww w . j a v a 2s . c om mbTable = new PdfPTable(11); mbTable.setWidths(new float[] { 1f, 1.5f, 4f, 1.9f, 1.6f, 1.4f, 1.8f, 1.9f, 1.9f, 1.9f, 1.6f }); } // main table mbTable.setWidthPercentage(100); try { final Font font = new Font(); font.setSize(8); mbTable.getDefaultCell().setPadding(3); mbTable.getDefaultCell().setBorderWidth(1); mbTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.slno"), font))); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.schno"), font))); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.descofwork"), font))); if (includeRevisionTypeColumn) mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.revisiontype"), font))); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.completedmeasurement"), font))); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.unitrate"), font))); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.unit"), font))); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.totalvalueofcomplwork"), font))); // start creating tables for previous measurements final PdfPTable previousMbTable = createPreviousMbTable(); final PdfPCell previousMbCell = new PdfPCell(previousMbTable); previousMbCell.setColspan(2); mbTable.addCell(previousMbCell); mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.currentmeasurement"), font))); // last column mbTable.addCell(new PdfPCell(new Phrase(pdfLabel.get("mbpdf.currentcost"), font))); } catch (final RuntimeException e) { throw new ApplicationRuntimeException(MEASUREMENTBOOK_PDF_ERROR, e); } return mbTable; }
From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java
License:Open Source License
private PdfPTable createApprovalDetailsTable(final TenderResponse tenderResponse) throws DocumentException { try {/*from ww w .j a va 2s . c o m*/ final PdfPTable approvaldetailsTable = new PdfPTable(5); approvaldetailsTable.setWidthPercentage(100); approvaldetailsTable.setWidths(new float[] { 1f, 1f, 2f, 1.5f, 2f }); addRow(approvaldetailsTable, true, makePara(pdfLabel.get("tenderNegotiationpdf.aprvalstep")), centerPara(pdfLabel.get("tenderNegotiationpdf.name")), centerPara(pdfLabel.get("tenderNegotiationpdf.designation")), centerPara(pdfLabel.get("tenderNegotiationpdf.aprvdon")), centerPara(pdfLabel.get("tenderNegotiationpdf.remarks"))); List<StateHistory<Position>> history = null; if (tenderResponse.getCurrentState() != null && tenderResponse.getCurrentState().getHistory() != null) history = tenderResponse.getStateHistory(); if (history != null) { Collections.reverse(history); StateHistory<Position> previous = null; for (final StateHistory<Position> ad : history) { if (!ad.getValue().equals("NEW") && !ad.getValue().equals("APPROVAL_PENDING") && !ad.getValue().equals("END") && previous != null) { final EgwStatus status = (EgwStatus) getPersistenceService() .find("from EgwStatus where code=?", ad.getValue()); final PersonalInformation emp = employeeService.getEmpForPositionAndDate( ad.getCreatedDate(), Integer.parseInt(previous.getOwnerPosition().getId().toString())); addRow(approvaldetailsTable, true, makePara(status.getDescription()), makePara(emp.getEmployeeName()), makePara(previous.getOwnerPosition().getDeptDesig().getDesignation().getName()), makePara(getDateInFormat(ad.getCreatedDate().toString())), rightPara(ad.getComments())); } previous = ad; } } return approvaldetailsTable; } catch (final Exception e) { throw new DocumentException("Exception occured while getting approval details " + e); } }
From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java
License:Open Source License
/** * create negotiation table main table//from ww w . j a v a2s .c o m * * @param tenderResponse * @return * @throws DocumentException * @throws ApplicationException */ private PdfPTable createNegotiationTable(final TenderResponse tenderResponse, final Contractor contractor) throws DocumentException { final PdfPTable negotiationTable = new PdfPTable(13); negotiationTable.setWidthPercentage(100); negotiationTable.setWidths( new float[] { 0.5f, 1f, 3.6f, 1.5f, 1.1f, 0.9f, 1.5f, 1.7f, 1.7f, 1.7f, 1.7f, 1.7f, 1.7f }); try { negotiationTable.getDefaultCell().setPadding(5); negotiationTable.getDefaultCell().setBorderWidth(1); negotiationTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); negotiationTable.addCell(pdfLabel.get("tenderNegotiationpdf.slno")); negotiationTable.addCell(pdfLabel.get("tenderNegotiationpdf.scheduleno")); negotiationTable.addCell(pdfLabel.get("tenderNegotiationpdf.descofwork")); negotiationTable.addCell(pdfLabel.get("tenderNegotiationpdf.quantity")); /** * start creating tables for Estimate, before negotion, after negotiation and marketRate */ final PdfPTable estimateTable = createAsPerEstimateTable(tenderResponse); estimateTable.setWidths(new float[] { 0.45f, 0.37f, 0.62f }); final PdfPCell estimateCell = new PdfPCell(estimateTable); estimateCell.setColspan(3); negotiationTable.addCell(estimateCell); final PdfPTable beforeNegotiationTable = createBeforeNegotiationTable(tenderResponse); final PdfPCell beforeNegotiationCell = new PdfPCell(beforeNegotiationTable); beforeNegotiationCell.setColspan(2); negotiationTable.addCell(beforeNegotiationCell); final PdfPTable afterNegotiationTable = createAfterNegotiationTable(tenderResponse); final PdfPCell afterNegotiationCell = new PdfPCell(afterNegotiationTable); afterNegotiationCell.setColspan(2); negotiationTable.addCell(afterNegotiationCell); final PdfPTable marketRateTable = createMarketRateTable(tenderResponse); final PdfPCell marketRateCell = new PdfPCell(marketRateTable); marketRateCell.setColspan(2); negotiationTable.addCell(marketRateCell); /** * end creating tables for before negotion, after negotiation and marketRate */ if (YES.equalsIgnoreCase(worksPackgeReq)) createNegotiationTableDataForWp(tenderResponse, negotiationTable, contractor); else createNegotiationTableData(tenderResponse, negotiationTable, contractor); createNegotiationTableFooter(negotiationTable); addRowFooter(negotiationTable); addTotalQuotedFooter(negotiationTable); addFinalRow(negotiationTable, tenderResponse); } catch (final DocumentException e) { throw new ApplicationRuntimeException(TENDER_PDF_ERROR, e); } return negotiationTable; }
From source file:org.egov.works.web.actions.tender.TenderNegotiationPDFGenerator.java
License:Open Source License
/** * create contractor table//from w w w. j a va2 s.c o m * * @param tenderResponse * @return * @throws DocumentException * @throws ApplicationException */ private PdfPTable createContractorTable(final TenderResponse tenderResponse) throws DocumentException { final PdfPTable contractorTable = new PdfPTable(3); contractorTable.setWidthPercentage(100); contractorTable.setWidths(new float[] { 1.6f, 3.6f, 6.6f }); try { contractorTable.getDefaultCell().setPadding(5); contractorTable.getDefaultCell().setBorderWidth(1); contractorTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); contractorTable.addCell(pdfLabel.get("tenderNegotiationpdf.contractorcode")); contractorTable.addCell(pdfLabel.get("tenderNegotiationpdf.contractorname")); contractorTable.addCell(pdfLabel.get("tenderNegotiationpdf.contractoraddress")); for (final TenderResponseContractors tenderResponseContractors : tenderResponse .getTenderResponseContractors()) { contractorTable.addCell(centerPara(tenderResponseContractors.getContractor().getCode())); contractorTable.addCell(centerPara(tenderResponseContractors.getContractor().getName())); contractorTable .addCell(centerPara(tenderResponseContractors.getContractor().getCorrespondenceAddress())); } } catch (final Exception e) { LOGGER.info("Exception while creating contractor table" + e); } return contractorTable; }
From source file:org.gtdfree.addons.PDFExportAddOn.java
License:Open Source License
@Override public void export(GTDModel model, ActionsCollection collection, OutputStream out, ExportAddOn.ExportOrder order, FileFilter ff, boolean compact) throws Exception { fontSelector = new FontSelector(); fontSelectorB = new FontSelector(); fontSelectorB2 = new FontSelector(); fontSelectorB4 = new FontSelector(); baseFont = fontModel.getBaseFont();/* w w w. j av a 2 s. c o m*/ for (BaseFont bf : fontModel.getFonts()) { fontSelector.addFont(new Font(bf, baseFontSize)); fontSelectorB.addFont(new Font(bf, baseFontSize, Font.BOLD)); fontSelectorB2.addFont(new Font(bf, baseFontSize + 2, Font.BOLD)); fontSelectorB4.addFont(new Font(bf, baseFontSize + 4, Font.BOLD)); } boolean emptyH2 = false; boolean emptyH3 = false; PdfPTable actionTable = null; Document doc = new Document(); if (sizeSet) { doc.setPageSize(pageSize); } if (marginSet) { doc.setMargins(marginLeft, marginRight, marginTop, marginBottom); } //System.out.println("PDF size "+doc.getPageSize().toString()); //System.out.println("PDF m "+marginLeft+" "+marginRight+" "+marginTop+" "+marginBottom); @SuppressWarnings("unused") PdfWriter pw = PdfWriter.getInstance(doc, out); doc.addCreationDate(); doc.addTitle("GTD-Free PDF"); doc.addSubject("GTD-Free data exported as PDF"); HeaderFooter footer = new HeaderFooter(newParagraph(), true); footer.setAlignment(HeaderFooter.ALIGN_CENTER); footer.setBorder(HeaderFooter.TOP); doc.setFooter(footer); doc.open(); Phrase ch = newTitle("GTD-Free Data"); Paragraph p = new Paragraph(ch); p.setAlignment(Paragraph.ALIGN_CENTER); PdfPTable t = new PdfPTable(1); t.setWidthPercentage(100f); PdfPCell c = newCell(p); c.setBorder(Table.BOTTOM); c.setBorderWidth(2.5f); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setPadding(5f); t.addCell(c); doc.add(t); Iterator<Object> it = collection.iterator(order); while (it.hasNext()) { Object o = it.next(); if (o == ActionsCollection.ACTIONS_WITHOUT_PROJECT) { if (order == ExportAddOn.ExportOrder.FoldersProjectsActions) { doc.add(newSubSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT)); emptyH2 = false; emptyH3 = true; } else { doc.add(newSection(ActionsCollection.ACTIONS_WITHOUT_PROJECT)); emptyH2 = true; emptyH3 = false; } continue; } if (o instanceof Folder) { Folder f = (Folder) o; if (actionTable != null) { doc.add(actionTable); actionTable = null; } if (f.isProject()) { if (order == ExportAddOn.ExportOrder.ProjectsActions || order == ExportAddOn.ExportOrder.ProjectsFoldersActions) { if (emptyH2 || emptyH3) { p = newParagraph(NONE_DOT); doc.add(p); } doc.add(newSection(f.getName())); if (compact) { if (f.getDescription() != null && f.getDescription().length() > 0) { p = newParagraph(f.getDescription()); p.setIndentationLeft(10f); p.setIndentationRight(10f); doc.add(p); } } else { t = new PdfPTable(2); t.setKeepTogether(true); t.setSpacingBefore(5f); t.setWidthPercentage(66f); t.setWidths(new float[] { 0.33f, 0.66f }); c = newCell("ID"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.getId()))); t.addCell(c); c = newCell("Type"); t.addCell(c); c = newCell(newStrongParagraph("Project")); t.addCell(c); c = newCell("Open"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount()))); t.addCell(c); c = newCell("All"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.size()))); t.addCell(c); c = newCell("Description"); t.addCell(c); c = newDescriptionCell(f.getDescription()); t.addCell(c); doc.add(t); } emptyH2 = true; emptyH3 = false; } else { if (emptyH3) { p = newParagraph(NONE_DOT); doc.add(p); } doc.add(newSubSection("Project:" + " " + f.getName())); emptyH2 = false; emptyH3 = true; } continue; } if (order == ExportAddOn.ExportOrder.FoldersActions || order == ExportAddOn.ExportOrder.FoldersProjectsActions) { if (emptyH2 || emptyH3) { p = newParagraph(NONE_DOT); doc.add(p); } doc.add(newSection(f.getName())); if (compact) { if (f.getDescription() != null && f.getDescription().length() > 0) { p = newParagraph(f.getDescription()); p.setIndentationLeft(10f); p.setIndentationRight(10f); doc.add(p); } } else { t = new PdfPTable(2); t.setKeepTogether(true); t.setSpacingBefore(5f); t.setWidthPercentage(66f); t.setWidths(new float[] { 0.33f, 0.66f }); c = newCell("ID"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.getId()))); t.addCell(c); String type = ""; if (f.isAction()) { type = "Action list"; } else if (f.isInBucket()) { type = "In-Bucket"; } else if (f.isQueue()) { type = "Next action queue"; } else if (f.isReference()) { type = "Reference list"; } else if (f.isSomeday()) { type = "Someday/Maybe list"; } else if (f.isBuildIn()) { type = "Default list"; } c = newCell("Type"); t.addCell(c); c = newCell(newStrongParagraph(type)); t.addCell(c); c = newCell("Open"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.getOpenCount()))); t.addCell(c); c = newCell("All"); t.addCell(c); c = newCell(newStrongParagraph(String.valueOf(f.size()))); t.addCell(c); c = newCell("Description"); t.addCell(c); c = newDescriptionCell(f.getDescription()); t.addCell(c); doc.add(t); } emptyH2 = true; emptyH3 = false; } else { if (emptyH3) { p = newParagraph(NONE_DOT); doc.add(p); } doc.add(newSubSection("List:" + " " + f.getName())); emptyH2 = false; emptyH3 = true; } continue; } if (o instanceof Action) { emptyH2 = false; emptyH3 = false; Action a = (Action) o; if (compact) { if (actionTable == null) { actionTable = new PdfPTable(5); actionTable.setWidthPercentage(100f); actionTable.setHeaderRows(1); actionTable.setSpacingBefore(5f); c = newHeaderCell("ID"); actionTable.addCell(c); c = newHeaderCell("Pri."); actionTable.addCell(c); c = newHeaderCell("Description"); actionTable.addCell(c); c = newHeaderCell("Reminder"); actionTable.addCell(c); c = newHeaderCell(CHECK_RESOLVED); actionTable.addCell(c); float width = doc.getPageSize().getWidth() - doc.getPageSize().getBorderWidthLeft() - doc.getPageSize().getBorderWidthRight(); int i = model.getLastActionID(); float step = baseFontSize - 1; int steps = (int) Math.floor(Math.log10(i)) + 1; // ID column float col1 = 8 + steps * step; // Priority column float col2 = 4 + 3 * (baseFontSize + 4); // Reminder column float col4 = 10 + step * 11; // Resolved column float col5 = 8 + baseFontSize; // Description column float col3 = width - col1 - col2 - col4 - col5; actionTable.setWidths(new float[] { col1, col2, col3, col4, col5 }); } addSingleActionRow(a, actionTable); } else { addSingleActionTable(model, doc, a); } } } if (actionTable != null) { doc.add(actionTable); actionTable = null; } if (emptyH2 || emptyH3) { p = newParagraph(NONE_DOT); doc.add(p); } //w.writeCharacters("Exported: "+ApplicationHelper.toISODateTimeString(new Date())); doc.close(); }