List of usage examples for com.itextpdf.text.pdf PdfPCell setUseAscender
public void setUseAscender(boolean useAscender)
From source file:com.hris.payroll.reports.PayslipReportPDF.java
private PdfPTable leftColumnTable(PayrollRegister pr, Date payrollDate) throws DocumentException { PdfPTable table = new PdfPTable(3); table.setTotalWidth(new float[] { 120, 20, 103 }); table.setWidthPercentage(100);//from ww w.java 2 s . c o m table.setHorizontalAlignment(Element.ALIGN_LEFT); table.setLockedWidth(true); PdfPCell cellTitle = new PdfPCell(); cellTitle.setColspan(3); Paragraph parTitle = new Paragraph(); parTitle.add(new Phrase("Payslip: ", header)); parTitle.setAlignment(Element.ALIGN_CENTER); cellTitle.addElement(parTitle); cellTitle.setBorder(cellBorder); table.addCell(cellTitle); PdfPCell cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(3); Paragraph parLabel = new Paragraph(); parLabel.add( new Phrase("Payroll Date: " + CommonUtil.convertDateFormat(getPayrollDate().toString()), content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); // PdfPCell cellValue = new PdfPCell(); // cellValue.setUseAscender(true); // Paragraph parValue = new Paragraph(); // parValue.add(new Phrase(CommonUtil.convertDateFormat(getPayrollDate().toString()), content)); // parValue.setAlignment(Element.ALIGN_RIGHT); // cellValue.addElement(parValue); // cellValue.setBorder(cellBorder); // table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(3); parLabel = new Paragraph(); parLabel.add( new Phrase( "Cut-off Date: " + CommonUtil.changeDateFormat(pr.getAttendancePeriodFrom().toString()) + " - " + CommonUtil.changeDateFormat(pr.getAttendancePeriodTo().toString()), content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); // PdfPCell cellValue = new PdfPCell(); // cellValue.setUseAscender(true); // Paragraph parValue = new Paragraph(); // parValue.add(new Phrase(CommonUtil.convertDateFormat(pr.getAttendancePeriodFrom().toString())+" - "+CommonUtil.convertDateFormat(pr.getAttendancePeriodFrom().toString()), content)); // parValue.setAlignment(Element.ALIGN_RIGHT); // cellValue.addElement(parValue); // cellValue.setBorder(cellBorder); // table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(3); parLabel = new Paragraph(); String middlename; if (pr.getMiddlename() == null || pr.getMiddlename().isEmpty()) { middlename = " "; } else { middlename = String.valueOf(pr.getMiddlename().toUpperCase().charAt(0)) + ". "; } String name = pr.getLastname().toUpperCase() + ", " + pr.getFirstname().toUpperCase() + " " + middlename; parLabel.add(new Phrase("Employee Name: " + name, content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); // cellValue = new PdfPCell(); //// cellValue.setUseAscender(true); // parValue = new Paragraph(); // parValue.add(new Phrase(pr.getLastname().toUpperCase()+", "+pr.getFirstname().toUpperCase()+" "+pr.getMiddlename().toUpperCase().charAt(0)+".", employeeName)); //// parValue.add(new Phrase("NAME", content)); // parValue.setAlignment(Element.ALIGN_RIGHT); // cellValue.addElement(parValue); // cellValue.setBorder(cellBorder); // table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(3); parLabel = new Paragraph(); String position = (ephs.findByEmployee(pr.getEmployeeId()).getPosition() == null) ? "N/A" : ephs.findByEmployee(pr.getEmployeeId()).getPosition().toUpperCase(); parLabel.add(new Phrase("POSITION: " + position, smallerFont)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); // cellValue = new PdfPCell(); // cellValue.setUseAscender(true); // parValue = new Paragraph(); // parValue.add(new Phrase(CommonUtil.convertDateFormat(new Date().toString()), content)); // parValue.setAlignment(Element.ALIGN_RIGHT); // cellValue.addElement(parValue); // cellValue.setBorder(cellBorder); // table.addCell(cellValue); cellLabel = new PdfPCell(); // cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.add(new Phrase("Monthly/Daily Rate: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); PdfPCell cellValue = new PdfPCell(); // cellValue.setUseAscender(true); Paragraph parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getRate()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.add(new Phrase("Half-month Rate: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getHalfMonthSalary()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Overtime: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add( new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getOvertimePay())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Holiday Premium: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); double premium = (pr.getLegalHolidayPay() + pr.getSpecialHolidayPay()) - (pr.getTotalLatesHolidayDeduction() + pr.getTotalUndertimeHolidayDeduction()); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(premium)), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Working Day-off: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getWorkingDayOffPay())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Night Differential: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getNightDifferential())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Absences/Lates/Undertime: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); double alu = pr.getAbsences() + pr.getTotalLatesDeduction() + pr.getTotalUndertimeDeduction(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(alu)), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.add(new Phrase("GROSS PAY: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getGrossPay())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(Rectangle.TOP | Rectangle.BOTTOM); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Allowances: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(" ", content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("COLA: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getColaAllowance()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Meal Allowance: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getMealAllowance()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("AFL: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getAllowanceForLiquidation()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Transportation Allowance: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); cellLabel.setColspan(2); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getTransportationAllowance()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Housing Allowance: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getOtherAllowance()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Communications Allowance: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(pr.getCommunicationAllowance()), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.add(new Phrase("TOTAL PAY: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); double totalPay = pr.getGrossPay() + pr.getCommunicationAllowance() + pr.getTransportationAllowance() + pr.getColaAllowance() + pr.getPerDiemAllowance() + pr.getMealAllowance() + pr.getOtherAllowance() + pr.getAllowanceForLiquidation(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(totalPay)), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(Rectangle.TOP | Rectangle.BOTTOM); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.add(new Phrase("DEDUCTIONS: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(" ", content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("SSS Contribution: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getSss())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("PHIC Contribution: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getPhic())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("HDMF Contribution: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getHdmf())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Withholoding Taxes: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getTax())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("SSS Loan: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "sss loan"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("HDMF Loan: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "hdmf loan"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Additional HDMF Contribution: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add( new Phrase( String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces( as.findAdvancesTotalAmount(pr.getPayrollId(), "additional HDMF contribution"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("PAG-IBIG 2: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "pag-ibig ii"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Advances to O/E: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(" ", content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Cash Bond: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "cash bond"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Cash Advance: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "cash advance"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Lending: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "lending"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Jewelry: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "jewelry"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Staffhouse: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase( String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "staffhouse"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Hotel and Restaurant Charges: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add( new Phrase( String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces( as.findAdvancesTotalAmount(pr.getPayrollId(), "hotel and restaurant charges"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Cash Shortages: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "cash shortages"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Employee Charges: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "employee charges"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("ATM Initial Deposit: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil .roundOffToTwoDecimalPlaces(as.findAdvancesTotalAmount(pr.getPayrollId(), "atm initial deposit"))), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.setIndentationLeft(allowances); parLabel.add(new Phrase("Others__________________: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); double otherCharges = as.findAdvancesTotalAmount(pr.getPayrollId(), "advances to o/e") + as.findAdvancesTotalAmount(pr.getPayrollId(), "other charges"); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(otherCharges)), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.add(new Phrase("TOTAL DEDUCTIONS:", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); double totalDeductions = as.findAdvancesTotalAmount(pr.getPayrollId()) + pr.getTax() + pr.getPhic() + pr.getHdmf() + pr.getSss(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(totalDeductions)), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(Rectangle.TOP | Rectangle.BOTTOM); table.addCell(cellValue); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); cellLabel.setColspan(2); parLabel = new Paragraph(); parLabel.add(new Phrase("NET PAY:", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); double netPay = CommonUtil.roundOffToTwoDecimalPlaces(totalPay - totalDeductions); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(netPay)), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); /***************************************************************************/ cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); parLabel = new Paragraph(); parLabel.add(new Phrase("Adjustments:", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); parLabel = new Paragraph(); parLabel.add(new Phrase(" ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add( new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(pr.getAdjustments())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); /***************************************************************************/ cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); parLabel = new Paragraph(); // parLabel.add(new Phrase("_____________________________", content)); parLabel.add(new Phrase(" ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(Rectangle.TOP | Rectangle.BOTTOM); table.addCell(cellLabel); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); parLabel = new Paragraph(); parLabel.add(new Phrase(" ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); // parValue.add(new Phrase(String.valueOf(totalPay - totalDeductions), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); /***************************************************************************/ cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); parLabel = new Paragraph(); parLabel.add(new Phrase("TOTAL AMOUNT TO BE RECEIVED:", smallFont)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); parLabel = new Paragraph(); parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase(" ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase(String.valueOf(CommonUtil.roundOffToTwoDecimalPlaces(netPay + pr.getAdjustments())), content)); parValue.setAlignment(Element.ALIGN_RIGHT); cellValue.addElement(parValue); cellValue.setBorder(Rectangle.TOP | Rectangle.BOTTOM); table.addCell(cellValue); /***************************************************************************/ cellLabel = new PdfPCell(); // cellLabel.setUseAscender(true); parLabel = new Paragraph(); parLabel.add(new Phrase("Prepared By: ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellLabel = new PdfPCell(); // cellLabel.setUseAscender(true); parLabel = new Paragraph(); parLabel.add(new Phrase(" ", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); // cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase("Conforme: ", content)); parValue.setAlignment(Element.ALIGN_LEFT); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); /***************************************************************************/ int userId = ubas.findUserByBranch(getBranchId()); String employeeId = us.findEmployeeIdByUserId(userId); Employee e = es.findEmployeeById(employeeId); String payrollClerkMiddlename; if (e.getMiddlename() == null || e.getMiddlename().isEmpty()) { payrollClerkMiddlename = " "; } else { payrollClerkMiddlename = String.valueOf(e.getMiddlename().toUpperCase().charAt(0)) + ". "; } String payrollClerk = e.getFirstname().toUpperCase() + " " + payrollClerkMiddlename + e.getLastname().toUpperCase(); String employeeMiddlename; if (pr.getMiddlename() == null || pr.getMiddlename().isEmpty()) { employeeMiddlename = " "; } else { employeeMiddlename = String.valueOf(pr.getMiddlename().toUpperCase().charAt(0)) + ". "; } String employee = pr.getFirstname().toUpperCase() + " " + employeeMiddlename + pr.getLastname().toUpperCase(); cellLabel = new PdfPCell(); cellLabel.setPaddingTop(30); parLabel = new Paragraph(); parLabel.add(new Phrase(payrollClerk, smallerFont)); parLabel.setAlignment(Element.ALIGN_CENTER); cellLabel.addElement(parLabel); cellLabel.setBorder(Rectangle.BOTTOM); table.addCell(cellLabel); cellLabel = new PdfPCell(); cellLabel.setPaddingTop(30); parLabel = new Paragraph(); parLabel.add(new Phrase(" ", content)); parLabel.setAlignment(Element.ALIGN_CENTER); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setPaddingTop(30); parValue = new Paragraph(); parValue.add(new Phrase(employee, smallerFont)); parValue.setAlignment(Element.ALIGN_CENTER); cellValue.addElement(parValue); cellValue.setBorder(Rectangle.BOTTOM); table.addCell(cellValue); /***************************************************************************/ cellLabel = new PdfPCell(); cellLabel.setUseAscender(true); parLabel = new Paragraph(); // parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("Payroll Clerk", content)); parLabel.setAlignment(Element.ALIGN_CENTER); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellLabel = new PdfPCell(); parLabel = new Paragraph(); // parLabel.setIndentationLeft(halfMonthRate); parLabel.add(new Phrase("", content)); parLabel.setAlignment(Element.ALIGN_LEFT); cellLabel.addElement(parLabel); cellLabel.setBorder(cellBorder); table.addCell(cellLabel); cellValue = new PdfPCell(); cellValue.setUseAscender(true); parValue = new Paragraph(); parValue.add(new Phrase("Employee", content)); parValue.setAlignment(Element.ALIGN_CENTER); cellValue.addElement(parValue); cellValue.setBorder(cellBorder); table.addCell(cellValue); return table; }
From source file:jsimpresos.ConexionNotas.java
public void generarPdf(int idNota, String nombre, int cuenta) { Document documento = new Document(); Nota nota = this.getNotaPorId(idNota); FileOutputStream ficheroPdf;/*ww w.ja v a 2s.c o m*/ try { File carpeta = new File("C:\\archivosPuntoDeVenta"); if (!carpeta.exists()) { carpeta.mkdir(); } ficheroPdf = new FileOutputStream("c:/archivosPuntoDeVenta/" + nombre + cuenta + ".pdf"); PdfWriter.getInstance(documento, ficheroPdf).setInitialLeading(20); documento.setMargins(0, 0, 0, 0); documento.open(); Image foto = Image.getInstance("c:/archivosPuntoDeVenta/logo.JPG"); foto.scaleToFit(80, 90); PdfPTable tabla = new PdfPTable(5); tabla.setWidths(new float[] { 13, 12, 25, 25, 25 }); tabla.setWidthPercentage(100); PdfPCell celda = new PdfPCell(); celda.addElement(foto); celda.setBorder(Rectangle.NO_BORDER); celda.setRowspan(6); tabla.addCell(celda); PdfPCell celda2 = new PdfPCell( new Paragraph("NOTA DE PEDIDO", FontFactory.getFont("Arial", 15, Font.BOLD))); System.out.println(nota.getUsuario()); celda2.setColspan(3); celda2.setUseAscender(true); celda2.setBorder(Rectangle.NO_BORDER); celda2.setVerticalAlignment(Element.ALIGN_MIDDLE); tabla.addCell(celda2); PdfPCell celdaFecha = new PdfPCell(new Paragraph("Fecha: " + nota.getFecha())); celdaFecha.setBorder(Rectangle.NO_BORDER); tabla.addCell(celdaFecha); PdfPCell celda3 = new PdfPCell(new Phrase("Calle del Rayo y 2 de Abril 31a. Col. centro, Parral, Chih.", FontFactory.getFont("Arial", 7, Font.BOLD, BaseColor.RED))); celda3.setColspan(2); celda3.setBorder(Rectangle.NO_BORDER); tabla.addCell(celda3); PdfPCell celda4 = new PdfPCell(new Phrase("Tel. 5230073 y 6271034745", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.RED))); celda4.setBorder(Rectangle.NO_BORDER); tabla.addCell(celda4); Paragraph p = new Paragraph("No. " + nota.getIdNota(), FontFactory.getFont("Arial", 13, Font.BOLD, BaseColor.RED)); PdfPCell celda5 = new PdfPCell(); celda5.setUseAscender(true); celda5.setVerticalAlignment(Element.ALIGN_MIDDLE); celda5.setHorizontalAlignment(Element.ALIGN_MIDDLE); celda5.addElement(p); tabla.addCell(celda5); PdfPCell celdanueva = new PdfPCell( new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celdanueva.setBorder(Rectangle.NO_BORDER); celdanueva.setColspan(4); tabla.addCell(celdanueva); PdfPCell celdanueva1 = new PdfPCell( new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celdanueva1.setBorder(Rectangle.NO_BORDER); tabla.addCell(celdanueva1); PdfPCell celdanueva2 = new PdfPCell( new Phrase("Datos del cliente", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celdanueva2.setBorder(Rectangle.NO_BORDER); celdanueva2.setColspan(3); tabla.addCell(celdanueva2); PdfPCell celdanueva3 = new PdfPCell( new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celdanueva3.setBorder(Rectangle.NO_BORDER); tabla.addCell(celdanueva3); if (nota.getCliente() == null) { PdfPCell celda6 = new PdfPCell( new Phrase("Cliente: " + nota.getNombres() + " " + nota.getApPaterno(), FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celda6.setBorder(Rectangle.NO_BORDER); celda6.setColspan(3); tabla.addCell(celda6); PdfPCell celdanueva4 = new PdfPCell( new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celdanueva4.setBorder(Rectangle.NO_BORDER); tabla.addCell(celdanueva4); PdfPCell celda7 = new PdfPCell(new Phrase("Domicilio: " + nota.getDomicilio(), FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celda7.setBorder(Rectangle.NO_BORDER); celda7.setColspan(2); tabla.addCell(celda7); PdfPCell celda8 = new PdfPCell(new Phrase("Telfono: " + nota.getTelefono(), FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celda8.setBorder(Rectangle.NO_BORDER); tabla.addCell(celda8); } else { PdfPCell celda6 = new PdfPCell(new Phrase( "Cliente: " + nota.getCliente().getNombres() + " " + nota.getCliente().getApPaterno(), FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celda6.setBorder(Rectangle.NO_BORDER); celda6.setColspan(3); tabla.addCell(celda6); PdfPCell celdanueva4 = new PdfPCell( new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celdanueva4.setBorder(Rectangle.NO_BORDER); tabla.addCell(celdanueva4); PdfPCell celda7 = new PdfPCell(new Phrase("Domicilio: " + nota.getCliente().getDomicilio(), FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celda7.setBorder(Rectangle.NO_BORDER); celda7.setColspan(2); tabla.addCell(celda7); PdfPCell celda8 = new PdfPCell(new Phrase("Telfono: " + nota.getCliente().getTelefono(), FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celda8.setBorder(Rectangle.NO_BORDER); tabla.addCell(celda8); } PdfPTable tabla2 = new PdfPTable(4); tabla2.setWidths(new float[] { 10, 70, 15, 15 }); tabla2.setWidthPercentage(99.5f); PdfPCell celda21 = new PdfPCell( new Phrase("Cantidad", FontFactory.getFont("Arial", 11, Font.BOLD, BaseColor.BLACK))); tabla2.addCell(celda21); PdfPCell celda22 = new PdfPCell( new Phrase("Artculo", FontFactory.getFont("Arial", 11, Font.BOLD, BaseColor.BLACK))); tabla2.addCell(celda22); PdfPCell celda23 = new PdfPCell( new Phrase("Precio unitario", FontFactory.getFont("Arial", 11, Font.BOLD, BaseColor.BLACK))); tabla2.addCell(celda23); PdfPCell celda24 = new PdfPCell( new Phrase("Total", FontFactory.getFont("Arial", 11, Font.BOLD, BaseColor.BLACK))); tabla2.addCell(celda24); double total = 0; for (int i = 0; i < 6; i++) { if (i < nota.getArticulos().size()) { PdfPCell celda25 = new PdfPCell(new Phrase(nota.getArticulos().get(i).getCantidad() + "", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); tabla2.addCell(celda25); PdfPCell celda26 = new PdfPCell(new Phrase(nota.getArticulos().get(i).getServicio() + "", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); tabla2.addCell(celda26); PdfPCell celda27 = new PdfPCell(new Phrase(nota.getArticulos().get(i).getPrecio() + "", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); tabla2.addCell(celda27); PdfPCell celda28 = new PdfPCell(new Phrase( (nota.getArticulos().get(i).getCantidad() * nota.getArticulos().get(i).getPrecio()) + "", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); tabla2.addCell(celda28); total += nota.getArticulos().get(i).getCantidad() * nota.getArticulos().get(i).getPrecio(); } else { PdfPCell celda29 = new PdfPCell( new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); tabla2.addCell(celda29); tabla2.addCell(celda29); tabla2.addCell(celda29); tabla2.addCell(celda29); } } PdfPTable tabla3 = new PdfPTable(4); tabla3.setWidths(new float[] { 55, 25, 15, 15 }); tabla3.setWidthPercentage(99.5f); PdfPCell celda31 = new PdfPCell(new Phrase("Observaciones: " + nota.getObservaciones(), FontFactory.getFont("Arial", 9, BaseColor.BLACK))); celda31.setRowspan(4); tabla3.addCell(celda31); PdfPCell celda32 = new PdfPCell(new Phrase( "Suma recibida de abono : " + nota.getAbonos().get(nota.getAbonos().size() - 1).getMonto(), FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celda32.setRowspan(4); tabla3.addCell(celda32); PdfPCell celda33 = new PdfPCell( new Phrase("Total", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); tabla3.addCell(celda33); PdfPCell celda34 = new PdfPCell( new Phrase(total + "", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); tabla3.addCell(celda34); PdfPCell celda35 = new PdfPCell( new Phrase("Total abonado", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); tabla3.addCell(celda35); double totalAbonado = 0; for (int i = 0; i < nota.getAbonos().size(); i++) { totalAbonado += nota.getAbonos().get(i).getMonto(); } PdfPCell celda36 = new PdfPCell( new Phrase(totalAbonado + "", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); tabla3.addCell(celda36); PdfPCell celda37 = new PdfPCell( new Phrase("Saldo actual", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); tabla3.addCell(celda37); PdfPCell celda38 = new PdfPCell(new Phrase((total - totalAbonado) + "", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); tabla3.addCell(celda38); PdfPCell celda39 = new PdfPCell( new Phrase("Fecha entrega", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); tabla3.addCell(celda39); PdfPCell celda40 = new PdfPCell(new Phrase(nota.getFechaEntrega(), FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); tabla3.addCell(celda40); PdfPTable tabla4 = new PdfPTable(3); tabla4.setWidths(new float[] { 30, 30, 30 }); tabla4.setWidthPercentage(99.5f); PdfPCell celda41 = new PdfPCell( new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celda41.setBorder(Rectangle.NO_BORDER); celda41.setColspan(3); tabla4.addCell(celda41); PdfPCell celda42 = new PdfPCell( new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celda42.setBorder(Rectangle.NO_BORDER); tabla4.addCell(celda42); PdfPCell celda43 = new PdfPCell(new Phrase("Firma de conformidad del cliente: ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celda43.setBorder(Rectangle.NO_BORDER); tabla4.addCell(celda43); PdfPCell celda44 = new PdfPCell( new Phrase(" ", FontFactory.getFont("Arial", 10, Font.BOLD, BaseColor.BLACK))); celda44.setBorder(Rectangle.NO_BORDER); tabla4.addCell(celda44); tabla4.addCell(celda41); tabla4.addCell(celda41); tabla4.addCell(celda41); documento.add(tabla); documento.add(tabla2); documento.add(tabla3); documento.add(tabla4); documento.add(tabla); documento.add(tabla2); documento.add(tabla3); documento.add(tabla4); documento.close(); abrirPDF("c:/archivosPuntoDeVenta/" + nombre + cuenta + ".pdf"); } catch (FileNotFoundException ex) { // JOptionPane.showMessageDialog(null, "Error con el pdf"); // System.out.println(ex.getMessage()); cuenta++; generarPdf(idNota, "nota", cuenta); abrirPDF("c:/archivosPuntoDeVenta/" + nombre + cuenta + ".pdf"); } catch (DocumentException ex) { JOptionPane.showMessageDialog(null, "Error al guardar pdf"); System.out.println(ex.getMessage()); } catch (IOException ex) { JOptionPane.showMessageDialog(null, "Error con el pdf"); } }
From source file:se.billes.pdf.renderer.model.text.TableParagraph.java
License:Open Source License
@Override public void onRender(PdfPCell cell) throws PdfRenderException { PdfPTable table = new PdfPTable(widths.length); try {/*w w w.j a va 2 s . c om*/ table.setTotalWidth(getTotalWidthsAsPs()); table.setLockedWidth(true); table.setSpacingAfter(0f); for (AbstractParagraph tableCell : cells) { PdfPCell c = new PdfPCell(); float[] padding = new float[] { 0f, 0f, 0f, 0f }; if (tableCell instanceof TableCell) { padding = ((TableCell) tableCell).getPadding(); } c.setBorderWidth(0f); c.setLeft(0); c.setTop(0); c.setRight(0); c.setBottom(0); c.setUseAscender(true); c.setIndent(0); c.setHorizontalAlignment(Element.ALIGN_LEFT); c.setVerticalAlignment(Element.ALIGN_TOP); c.setPaddingLeft(SizeFactory.millimetersToPostscriptPoints(padding[0])); c.setPaddingBottom(SizeFactory.millimetersToPostscriptPoints(padding[3])); c.setPaddingRight(SizeFactory.millimetersToPostscriptPoints(padding[2])); c.setPaddingTop(SizeFactory.millimetersToPostscriptPoints(padding[1])); c.setBorder(0); tableCell.onRender(c); table.addCell(c); } cell.addElement(table); } catch (Exception e) { throw new PdfRenderException(e); } }
From source file:se.billes.pdf.renderer.request.factory.CellFactory.java
License:Open Source License
public PdfPCell createCell(Block block) { float[] margins = block.getMargins(); PdfPCell cell = new PdfPCell(); cell.setBorderWidth(0);//from ww w . j a va 2 s . co m cell.setVerticalAlignment(VerticalAlign.getByName(block.getVerticalAlign()).getAlignment()); cell.setLeft(0); cell.setTop(0); cell.setRight(0); cell.setBottom(0); cell.setUseAscender(block.isUseAscender()); cell.setIndent(0); cell.setPaddingLeft(SizeFactory.millimetersToPostscriptPoints(margins[0])); cell.setPaddingBottom(SizeFactory.millimetersToPostscriptPoints(margins[3])); cell.setPaddingRight(SizeFactory.millimetersToPostscriptPoints(margins[1])); cell.setPaddingTop(SizeFactory.millimetersToPostscriptPoints(margins[2])); cell.setFixedHeight(SizeFactory.millimetersToPostscriptPoints(block.getPosition()[3])); cell.setBorder(0); cell.setCellEvent(new CellBlockEvent().createEvent(block)); cell.setRotation(block.getRotation()); return cell; }
From source file:se.billes.pdf.renderer.request.factory.CellFactory.java
License:Open Source License
public PdfPCell getFillCell() { PdfPCell fillCell = new PdfPCell(); fillCell.setBorderWidth(0f);//from w w w .j ava 2 s .c om fillCell.setLeft(0); fillCell.setTop(0); fillCell.setRight(0); fillCell.setBottom(0); fillCell.setUseAscender(true); fillCell.setIndent(0); fillCell.setHorizontalAlignment(Element.ALIGN_LEFT); fillCell.setVerticalAlignment(Element.ALIGN_BOTTOM); fillCell.setPaddingLeft(0f); fillCell.setPaddingBottom(0f); fillCell.setPaddingRight(0f); fillCell.setPaddingTop(0f); fillCell.setBorder(0); renderEmptyCell(fillCell); return fillCell; }
From source file:timeclock.reports.EmployeeListReport.java
@Override public PdfPTable createTable(List list) { PdfPTable table = new PdfPTable(new float[] { 2, 3, 4, 1, 1 }); table.setWidthPercentage(100f);/*from www . j av a 2s .c om*/ PdfPCell dCell = table.getDefaultCell(); dCell.setUseAscender(true); dCell.setUseDescender(true); dCell.setPadding(3); dCell.setHorizontalAlignment(Element.ALIGN_CENTER); dCell.setBackgroundColor(BaseColor.DARK_GRAY); table.addCell(new Phrase("Employee ID", MyFonts.font.get("header"))); table.addCell(new Phrase("First Name", MyFonts.font.get("header"))); table.addCell(new Phrase("Last Name", MyFonts.font.get("header"))); table.addCell(new Phrase("Salary", MyFonts.font.get("header"))); table.addCell(new Phrase("Admin", MyFonts.font.get("header"))); dCell.setBackgroundColor(null); table.setHeaderRows(1); table.setFooterRows(0); // used for alternating row color int rowCount = 0; // Display all employees for (Object obj : list) { Employee emp = (Employee) obj; rowCount++; dCell.setBackgroundColor((rowCount % 2 == 0 ? BaseColor.LIGHT_GRAY : null)); table.addCell(new Paragraph(Integer.toString(emp.getEmployeeID()), MyFonts.font.get("normal"))); table.addCell(new Paragraph(emp.getFirstName(), MyFonts.font.get("normal"))); table.addCell(new Paragraph(emp.getLastName(), MyFonts.font.get("normal"))); table.addCell(new Paragraph(emp.getIsSalary_bool() ? "Yes" : "No", MyFonts.font.get("normal"))); table.addCell(new Paragraph(emp.getIsAdmin_bool() ? "Yes" : "No", MyFonts.font.get("normal"))); } return table; }
From source file:timeclock.reports.EmployeeTimeReport.java
@Override public PdfPTable createTable(List list) { // Create table and set basic table properties PdfPTable table = new PdfPTable(new float[] { 1, 4, 4, 3 }); table.setWidthPercentage(100f);//from w ww . ja v a2 s . c o m PdfPCell dCell = table.getDefaultCell(); dCell.setUseAscender(true); dCell.setUseDescender(true); dCell.setPadding(3); dCell.setHorizontalAlignment(Element.ALIGN_CENTER); // Set header background color dCell.setBackgroundColor(BaseColor.DARK_GRAY); // Display the employee first in header table.addCell(new Phrase(Integer.toString(employee.getEmployeeID()), MyFonts.font.get("header"))); table.addCell(new Phrase(employee.getFirstName(), MyFonts.font.get("header"))); table.addCell(new Phrase(employee.getLastName(), MyFonts.font.get("header"))); table.addCell(new Phrase("", MyFonts.font.get("header"))); // Display the column names in header table.addCell(new Phrase("", MyFonts.font.get("header"))); table.addCell(new Phrase("Time In", MyFonts.font.get("header"))); table.addCell(new Phrase("Time Out", MyFonts.font.get("header"))); table.addCell(new Phrase("Time Worked", MyFonts.font.get("header"))); // Reset the cell background color dCell.setBackgroundColor(null); // Set the number of rows included in the header and footer table.setHeaderRows(2); table.setFooterRows(0); // Make a variable to hold the total of all time worked long totalTimeDiff = 0; // used for alternating row color int rowCount = 0; // Display all time punches for (Object obj : list) { TimePunch tp = (TimePunch) obj; rowCount++; dCell.setBackgroundColor((rowCount % 2 == 0 ? BaseColor.LIGHT_GRAY : null)); Timestamp ts1, ts2; ts1 = tp.getPunchInTimestamp(); ts2 = tp.getPunchOutTimestamp(); totalTimeDiff += ts2.getTime() - ts1.getTime(); String id = Integer.toString(tp.getPunchId()); String in = DateUtils.getDateTimeFromTimestamp(ts1); String out = DateUtils.getDateTimeFromTimestamp(ts2); String diff = DateUtils.getTimestampDiff_Str(ts1, ts2); // Add information to row table.addCell(new Paragraph("", MyFonts.font.get("normal"))); table.addCell(new Paragraph(in, MyFonts.font.get("normal"))); table.addCell(new Paragraph(out, MyFonts.font.get("normal"))); table.addCell(new Paragraph(diff, MyFonts.font.get("normal"))); } // Set background to null dCell.setBackgroundColor(null); // Get total time worked and create a totals row table.addCell(new Paragraph("", MyFonts.font.get("normal"))); table.addCell(new Paragraph("", MyFonts.font.get("normal"))); table.addCell(new Paragraph("Total:", MyFonts.font.get("bold"))); table.addCell(new Paragraph(DateUtils.getTimeStrFromLong(totalTimeDiff), MyFonts.font.get("bold"))); return table; }