List of usage examples for com.itextpdf.text.pdf PdfPTable setWidthPercentage
public void setWidthPercentage(final float widthPercentage)
From source file:com.mobicage.rogerthat.enterprise.samples.hr.bizz.GenerateExpenseNote.java
License:Open Source License
public int handle(final User user, final User manager, final ExpenseNote en) throws MalformedURLException, IOException, DocumentException { log.info("Building list of expenses ..."); List<Expense> expenses = Expense.list(en); log.info("Retrieved " + expenses.size() + " expenses from the datastore"); log.info("Creating ExpenseNoteDocOutputStream"); ExpenseNoteDocOutputStream stream = new ExpenseNoteDocOutputStream(en); Document document = new Document(); PdfWriter.getInstance(document, stream); document.open();/*from w w w . j ava2 s . c o m*/ document.addTitle("Expense note " + en.id + " of " + user.name); document.addSubject("Expense note generated by Rogerthat Enterprise!"); document.addKeywords("expense note"); document.addAuthor(user.name); document.addCreator("Rogerthat OneApp Enterprise Mobility"); Paragraph preface = new Paragraph(); preface.add(new Paragraph("TP Vision expense note", titleFont)); preface.add(new Paragraph(" ")); DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy"); Date date = new Date(); preface.add(new Paragraph("Date: " + dateFormat.format(date))); preface.add(new Paragraph("Requestor: " + user.name)); preface.add(new Paragraph("Approver: " + manager.name)); preface.add(new Paragraph(" ")); PdfPTable table = new PdfPTable(7); table.setWidthPercentage(110); table.setWidths(new int[] { 5, 15, 15, 35, 10, 15, 10 }); addHeader(table, "Id"); addHeader(table, "Date"); addHeader(table, "Nature"); addHeader(table, "Description"); addHeader(table, "Account"); addHeader(table, "Amount"); addHeader(table, "Voucher"); table.setHeaderRows(1); Collections.sort(expenses, new Comparator<Expense>() { @Override public int compare(Expense e1, Expense e2) { return (int) (e1.date - e2.date); } }); int i = 0; double total = 0; for (Expense expense : expenses) { PdfPCell c1 = new PdfPCell(new Phrase("" + ++i)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.addCell(dateFormat.format(new Date(expense.date * 1000))); table.addCell(expense.nature); table.addCell(expense.description); table.addCell("" + expense.account); c1 = new PdfPCell(new Phrase(DECIMAL_FORMAT.format(expense.amount) + " " + expense.currency)); c1.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(c1); table.addCell(expense.voucher); total += expense.amount; } preface.add(table); preface.add(new Paragraph(" ")); preface.add(new Paragraph("Total: " + DECIMAL_FORMAT.format(total), titleFont)); document.add(preface); i = 0; for (Expense expense : expenses) { i++; if (expense.receipt == null) continue; document.newPage(); Paragraph receipt = new Paragraph(); receipt.add(new Paragraph("Attachment " + i, titleFont)); document.add(receipt); Image image = Image.getInstance(new URL(expense.receipt)); image.setRotationDegrees(-90); float scaler = (document.getPageSize().getWidth() / image.getWidth()) * 100; image.scalePercent(scaler); document.add(image); } document.close(); stream.close(); return stream.getSize(); }
From source file:com.myapp.struts.transaction.transactionAction.java
public ActionForward generatememberreport(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws SQLException, Exception { if (Constants.isSessionActive(request)) { transactionForm transactionForm = (transactionForm) form; try {// www. ja v a 2 s . c om Date utilDate = new Date(); java.sql.Date date = new java.sql.Date(utilDate.getTime()); Font bigFont = FontFactory.getFont(FontFactory.HELVETICA, "Windows-1254", 12, Font.BOLD, BaseColor.BLACK); Font bigFont_Uderline = FontFactory.getFont(FontFactory.HELVETICA, "Windows-1254", 12, Font.BOLD | Font.UNDERLINE, BaseColor.BLACK); Font boldfont = FontFactory.getFont(FontFactory.HELVETICA, "Windows-1254", 9, Font.BOLD); Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open(); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); //Or whatever format fits best your needs. Paragraph para1 = new Paragraph("PALKE JEWELLERS", bigFont); para1.setAlignment(Element.ALIGN_CENTER); document.add(para1); para1 = new Paragraph("MEMBER ACCOUNT DETAILS", bigFont); para1.setAlignment(Element.ALIGN_CENTER); document.add(para1); para1 = new Paragraph(transactionForm.getSelectedmember(), boldfont); para1.setAlignment(Element.ALIGN_LEFT); document.add(para1); para1 = new Paragraph( transactionForm.getMemberaddress() + "\n" + transactionForm.getMembercontactno(), boldfont); para1.setAlignment(Element.ALIGN_LEFT); document.add(para1); Groups obj = (Groups) hmGroups.get(transactionForm.getGroupid() + ""); if (obj != null) { para1 = new Paragraph("Group : " + obj.getGroupname(), font); para1.setAlignment(Element.ALIGN_LEFT); document.add(para1); para1 = new Paragraph("Paid Amount : " + transactionForm.getTotalpaidamount(), font); para1.setAlignment(Element.ALIGN_LEFT); document.add(para1); para1 = new Paragraph("Prize Amount : " + transactionForm.getDrawamount(), font); para1.setAlignment(Element.ALIGN_LEFT); document.add(para1); para1 = new Paragraph("Total Amount : " + transactionForm.getTotalamount(), boldfont); para1.setAlignment(Element.ALIGN_LEFT); document.add(para1); para1 = new Paragraph("Status : " + transactionForm.getStatus(), boldfont); para1.setAlignment(Element.ALIGN_RIGHT); document.add(para1); if (transactionForm.getStatus().equalsIgnoreCase("Settled")) { para1 = new Paragraph(transactionForm.getSettlementcomment(), boldfont); para1.setAlignment(Element.ALIGN_RIGHT); document.add(para1); } String dateStr = sdf.format(date); para1 = new Paragraph("DATED:" + dateStr, font); para1.setAlignment(Element.ALIGN_RIGHT); document.add(para1); // add a couple of blank lines document.add(Chunk.NEWLINE); if (transactionForm.getLstPayment() != null && transactionForm.getLstPayment().size() > 0) { PdfPTable table2 = new PdfPTable(7); float[] columnWidths = { 1.5f, 1.5f, 3f, 4f, 4f, 7f, 2f }; table2.setWidthPercentage(100); table2.setWidths(columnWidths); para1 = new Paragraph("Sl No.", font); para1.setAlignment(Element.ALIGN_CENTER); PdfPCell cell = new PdfPCell(para1); table2.addCell(cell); para1 = new Paragraph("Term", font); para1.setAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(para1); table2.addCell(cell); para1 = new Paragraph("Receipt No.", font); para1.setAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(para1); table2.addCell(cell); para1 = new Paragraph("Receipt Date", font); para1.setAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(para1); table2.addCell(cell); para1 = new Paragraph("Payment Mode", font); para1.setAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(para1); table2.addCell(cell); para1 = new Paragraph("Remarks", font); para1.setAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(para1); table2.addCell(cell); para1 = new Paragraph("Paid Amount", font); para1.setAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(para1); table2.addCell(cell); int x = 1; double total = 0; //Iterator it = hmPayments.entrySet().iterator(); //while (it.hasNext()) { if (hmPayments.size() > 0) { for (int i = 1; i <= obj.getNoofinstallment(); i++) { //float f = columnWidths[i]; Payment f1 = (Payment) hmPayments.get(i + ""); //} //Map.Entry pairs = (Map.Entry) it.next(); //Payment f1 = (Payment) pairs.getValue(); String term = i + ""; para1 = new Paragraph(Integer.toString(x), font); para1.setAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(para1); table2.addCell(cell); x++; para1 = new Paragraph(term, font); para1.setAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(para1); table2.addCell(cell); para1 = new Paragraph(f1.getPaymentid() + "", font); para1.setAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(para1); table2.addCell(cell); para1 = new Paragraph(sdf.format(f1.getPaiddate()), font); para1.setAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(para1); table2.addCell(cell); para1 = new Paragraph(f1.getPaymentmode() == 1 ? "Cash" : "Cheque/NEFT", font); para1.setAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(para1); table2.addCell(cell); para1 = new Paragraph(f1.getRemarks(), font); para1.setAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(para1); table2.addCell(cell); //para1 = new Paragraph(f1.getPaidamount() + "", boldfont); para1 = new Paragraph((int) obj.getInstallmentamount() + "", boldfont); para1.setAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(para1); table2.addCell(cell); total = total + obj.getInstallmentamount(); if (hmPayments.size() == i) { break; } } para1 = new Paragraph("Total", boldfont); para1.setAlignment(Element.ALIGN_LEFT); cell = new PdfPCell(para1); cell.setColspan(6); table2.addCell(cell); //String numberStr = String.format("%.2f", total + ""); para1 = new Paragraph(total + "", boldfont); para1.setAlignment(Element.ALIGN_CENTER); cell = new PdfPCell(para1); //cell.setColspan(7); table2.addCell(cell); table2.setHorizontalAlignment(Element.ALIGN_LEFT); document.add(table2); } else { para1 = new Paragraph("NO PAYMENTS FOUND", boldfont); para1.setAlignment(Element.ALIGN_CENTER); document.add(para1); } } else { para1 = new Paragraph("NO RECORDS FOUND", boldfont); para1.setAlignment(Element.ALIGN_CENTER); document.add(para1); } document.add(Chunk.NEWLINE); //document.close(); //fileInputStream = new FileInputStream(new File("C:\\reports\\PaymentReports.pdf")); document.close(); ServletOutputStream outputStream = response.getOutputStream(); baos.writeTo(outputStream); response.setHeader("Content-Disposition", "attachment; filename=\"PaymentStatusReport.pdf\""); response.setContentType("application/pdf"); outputStream.flush(); outputStream.close(); return mapping.findForward("display"); } else { para1 = new Paragraph("NO RECORDS FOUND", boldfont); para1.setAlignment(Element.ALIGN_CENTER); document.add(para1); document.close(); ServletOutputStream outputStream = response.getOutputStream(); baos.writeTo(outputStream); response.setHeader("Content-Disposition", "attachment; filename=\"PaymentStatusReport.pdf\""); response.setContentType("application/pdf"); outputStream.flush(); outputStream.close(); return mapping.findForward("display"); } } catch (DocumentException i) { System.out.println(i); return mapping.findForward("fail"); } catch (IOException i) { System.out.println(i); return mapping.findForward("fail"); } } else { return mapping.findForward("exp"); } }
From source file:com.mycom.products.mywebsite.backend.util.DownloadHandler.java
License:Open Source License
@RequestMapping(value = "/user/{id}", method = RequestMethod.GET) protected final void downloadUserInformation(@PathVariable int id, HttpServletRequest request, final HttpServletResponse response) throws ServletException, BusinessException, DocumentException { UserBean user = userService.select(id, FetchMode.EAGER); if (user == null) { return;//from w w w. ja va2 s . c o m } Document document = new Document(); document.setMargins(70, 70, 20, 20); try { response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "attachment; filename=\"" + user.getName() + "_profile.pdf\""); PdfWriter.getInstance(document, response.getOutputStream()); document.open(); Image profileImage = null; try { profileImage = Image.getInstance(user.getContent().getFilePath()); } catch (Exception e) { // e.printStackTrace(); } if (profileImage != null) { profileImage.setAlignment(Image.MIDDLE | Image.TEXTWRAP); profileImage.setBorder(Image.BOX); profileImage.setBorderWidth(5); BaseColor bgcolor = WebColors.getRGBColor("#E5E3E3"); profileImage.setBorderColor(bgcolor); profileImage.scaleToFit(100, 100); document.add(profileImage); } document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); // Adding Table Data PdfPTable table = new PdfPTable(2); // 2 columns. table.setWidthPercentage(100); // Width 100% table.setSpacingBefore(15f); // Space before table table.setSpacingAfter(15f); // Space after table // Set Column widths float[] columnWidths = { 1f, 2f, }; table.setWidths(columnWidths); // Name setTableHeader("Name", table); setTableContent(user.getName(), table); // Gender setTableHeader("Gender", table); String gender = "Male"; if (user.getGender() == Gender.FEMALE) { gender = "Female"; } setTableContent(gender, table); // Age setTableHeader("Age", table); setTableContent("" + user.getAge(), table); // Date of Birth setTableHeader("DOB", table); DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); setTableContent(dateFormatter.format(user.getDob()), table); // Email setTableHeader("Email", table); setTableContent(user.getEmail(), table); // NRC setTableHeader("NRC", table); setTableContent(user.getNrc(), table); // Phone setTableHeader("Phone", table); setTableContent(user.getPhone(), table); // Roles String roleStr = ""; List<RoleBean> roles = user.getRoles(); if (roles != null && roles.size() > 0) { Iterator<RoleBean> itr = roles.iterator(); while (itr.hasNext()) { RoleBean role = itr.next(); roleStr += role.getName(); if (itr.hasNext()) { roleStr += ","; } } } setTableHeader("Role(s)", table); setTableContent(roleStr, table); // Address setTableHeader("Address", table); setTableContent(user.getAddress(), table); document.add(table); document.add(new Paragraph(new Date().toString())); } catch (Exception e) { e.printStackTrace(); } document.close(); }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java
License:Apache License
private String createPdf(Context context) throws Exception { BscReportPropertyUtils.loadData();// www . j a v a 2s . co m BscReportSupportUtils.loadExpression(); // 2015-04-18 add String visionOid = (String) context.get("visionOid"); VisionVO vision = null; BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context); for (VisionVO visionObj : treeObj.getVisions()) { if (visionObj.getOid().equals(visionOid)) { vision = visionObj; } } FontFactory.register(BscConstants.PDF_ITEXT_FONT); String fileName = UUID.randomUUID().toString() + ".pdf"; String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName; OutputStream os = new FileOutputStream(fileFullPath); //Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); Document document = new Document(PageSize.A4, 10, 10, 10, 10); document.left(100f); document.top(150f); PdfWriter writer = PdfWriter.getInstance(document, os); document.open(); int dateRangeRows = 4 + vision.getPerspectives().get(0).getObjectives().get(0).getKpis().get(0) .getDateRangeScores().size(); PdfPTable table = new PdfPTable(MAX_COLSPAN); PdfPTable dateRangeTable = new PdfPTable(dateRangeRows); PdfPTable chartsTable = new PdfPTable(2); PdfPTable signTable = new PdfPTable(1); table.setWidthPercentage(100f); dateRangeTable.setWidthPercentage(100f); chartsTable.setWidthPercentage(100f); signTable.setWidthPercentage(100f); this.createHead(table, vision); this.createBody(table, vision); this.createDateRange(dateRangeTable, vision, context, dateRangeRows); this.putCharts(chartsTable, context); this.putSignature(signTable, context); document.add(chartsTable); document.add(table); document.add(dateRangeTable); document.add(signTable); document.close(); writer.close(); os.flush(); os.close(); os = null; File file = new File(fileFullPath); String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "kpi-report.pdf"); file = null; return oid; }
From source file:com.netsteadfast.greenstep.bsc.command.OrganizationReportPdfCommand.java
License:Apache License
private String createPdf(Context context) throws Exception { BscReportPropertyUtils.loadData();/*from w w w .j a v a2 s . co m*/ String visionOid = (String) context.get("visionOid"); VisionVO vision = null; BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context); for (VisionVO visionObj : treeObj.getVisions()) { if (visionObj.getOid().equals(visionOid)) { vision = visionObj; } } FontFactory.register(BscConstants.PDF_ITEXT_FONT); String fileName = UUID.randomUUID().toString() + ".pdf"; String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName; OutputStream os = new FileOutputStream(fileFullPath); Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); document.left(100f); document.top(150f); PdfWriter writer = PdfWriter.getInstance(document, os); document.open(); PdfPTable table = new PdfPTable(MAX_COLSPAN); table.setWidthPercentage(100f); PdfPTable signTable = new PdfPTable(1); signTable.setWidthPercentage(100f); this.createHead(table, vision, context); this.createBody(table, vision); this.putSignature(signTable, context); document.add(table); document.add(signTable); document.close(); writer.close(); os.flush(); os.close(); os = null; File file = new File(fileFullPath); String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "department-report.pdf"); file = null; return oid; }
From source file:com.netsteadfast.greenstep.bsc.command.PersonalReportPdfCommand.java
License:Apache License
private String createPdf(Context context) throws Exception { BscReportPropertyUtils.loadData();//from w w w. ja v a2s . c om String visionOid = (String) context.get("visionOid"); VisionVO vision = null; BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context); for (VisionVO visionObj : treeObj.getVisions()) { if (visionObj.getOid().equals(visionOid)) { vision = visionObj; } } FontFactory.register(BscConstants.PDF_ITEXT_FONT); String fileName = UUID.randomUUID().toString() + ".pdf"; String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName; OutputStream os = new FileOutputStream(fileFullPath); Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10); document.left(100f); document.top(150f); PdfWriter writer = PdfWriter.getInstance(document, os); document.open(); PdfPTable table = new PdfPTable(MAX_COLSPAN); table.setWidthPercentage(100f); PdfPTable signTable = new PdfPTable(1); signTable.setWidthPercentage(100f); this.createHead(table, vision, context); this.createBody(table, vision); this.createFoot(table, context); this.putSignature(signTable, context); document.add(table); document.add(signTable); document.close(); writer.close(); os.flush(); os.close(); os = null; File file = new File(fileFullPath); String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "personal-report.pdf"); file = null; return oid; }
From source file:com.norbsoft.pdfconverter.helpers.PDFHelper.java
License:Open Source License
private PdfPTable table(Form form) { int cellPadding = 5; PdfPTable table = new PdfPTable(8); table.setSpacingBefore(20);/*from www .j a v a 2 s . c o m*/ try { table.setWidths(new int[] { 100, 120, 30, 60, 60, 50, 50, 50 }); } catch (DocumentException e) { Log.e(TAG, "Width error:" + e.getMessage()); } PdfPCell cell = new PdfPCell(new Paragraph("Adres: " + form.getAddress(), normal)); cell.setColspan(8); cell.setPadding(cellPadding); cell.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP); cell.setBorderColorBottom(BaseColor.BLACK); table.addCell(cell); cell = new PdfPCell(new Paragraph("Odbiorca: " + form.getOwner(), normal)); cell.setColspan(8); cell.setPadding(cellPadding); cell.setBorder(Rectangle.LEFT | Rectangle.RIGHT); cell.setBorderColorBottom(BaseColor.BLACK); table.addCell(cell); cell = new PdfPCell(new Paragraph("Data: " + form.getDate(), normal)); cell.setColspan(3); cell.setPadding(cellPadding); cell.setBorder(Rectangle.LEFT | Rectangle.BOTTOM); cell.setBorderColorBottom(BaseColor.BLACK); table.addCell(cell); cell = new PdfPCell(new Paragraph("tel: " + form.getPhone(), normal)); cell.setColspan(5); cell.setPadding(cellPadding); cell.setBorder(Rectangle.RIGHT | Rectangle.BOTTOM); cell.setBorderColorBottom(BaseColor.BLACK); table.addCell(cell); //Header Paragraph p = new Paragraph("WODOMIERZ", bold); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setNoWrap(true); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph("Nr fabryczny", bold); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph("DN", bold); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph("Typ\r\nProducent", bold); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph("Stan w (m3)", bold); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph("Rok\r\nlegalizacji", bold); cell = new PdfPCell(p); ; cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph("Czy plomba\r\nlegalizacyjna jest\r\nuszkodzona?", bold); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); //First row cell = new PdfPCell(new Paragraph("Zamontowany", bold)); cell.setNoWrap(true); cell.setPadding(cellPadding); table.addCell(cell); p = new Paragraph(form.getNewSN(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getNewDN(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getNewType() + "\r\n" + form.getNewManufacturer(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getNewState(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getNewYear(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); if (form.getNewSeal().equals("Tak")) p = new Paragraph("tak", normal); else p = new Paragraph("tak", strike); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); if (form.getNewSeal().equals("Nie")) p = new Paragraph("nie", normal); else p = new Paragraph("nie", strike); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); //Second row cell = new PdfPCell(new Paragraph("Wymontowany", bold)); cell.setNoWrap(true); cell.setPadding(cellPadding); table.addCell(cell); p = new Paragraph(form.getOldSN(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getOldDN(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getOldType() + "\r\n" + form.getOldManufacturer(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getOldState(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); p = new Paragraph(form.getOldYear(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); if (form.getOldSeal().equals("Tak")) p = new Paragraph("tak", normal); else p = new Paragraph("tak", strike); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); if (form.getOldSeal().equals("Nie")) p = new Paragraph("nie", normal); else p = new Paragraph("nie", strike); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); //Third row cell = new PdfPCell(new Paragraph("Plomba nr 1", bold)); cell.setPadding(cellPadding); table.addCell(cell); p = new Paragraph(form.getSealFirst(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Paragraph("Przyczyna wymiany: " + form.getReason(), normal)); cell.setPadding(cellPadding); cell.setColspan(5); table.addCell(cell); //Fourth row cell = new PdfPCell(new Paragraph("Plomba nr 2", bold)); cell.setPadding(cellPadding); table.addCell(cell); p = new Paragraph(form.getSealSecond(), normal); cell = new PdfPCell(p); cell.setPadding(cellPadding); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); cell = new PdfPCell(new Paragraph("Umiejscowienie wodomierza: " + form.getPlacement(), normal)); cell.setPadding(cellPadding); cell.setColspan(5); table.addCell(cell); //Fourth row cell = new PdfPCell(new Paragraph("Nr moduu\r\nradiowego", bold)); cell.setPadding(cellPadding); table.addCell(cell); cell = new PdfPCell(new Paragraph(form.getNewModuleNumber(), normal)); cell.setPadding(cellPadding); cell.setColspan(7); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell); table.setWidthPercentage(100); return table; }
From source file:com.norbsoft.pdfconverter.helpers.PDFHelper.java
License:Open Source License
private PdfPTable signTable(Form form, Image sgn, ArrayList<String> workers) { int cellPadding = 5; PdfPTable table = new PdfPTable(2); table.setSpacingBefore(15);// w w w . java 2 s . co m PdfPCell cell = new PdfPCell(new Paragraph("Data i podpis klienta: ", normal)); cell.setPadding(cellPadding); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(new Paragraph("Wykonali pracownicy: ", normal)); cell.setPadding(cellPadding); cell.setBorder(0); table.addCell(cell); cell = new PdfPCell(sgn); cell.setRowspan(workers.size()); cell.setPadding(cellPadding); cell.setBorder(0); table.addCell(cell); for (int i = 0; i < workers.size(); i++) { cell = new PdfPCell(new Paragraph(workers.get(i), normal)); cell.setPadding(cellPadding); cell.setBorder(0); table.addCell(cell); } table.setWidthPercentage(90); return table; }
From source file:com.pdfs.GeneradorVisitas.java
public void addCreditosExpress(DatosVisitaDomiciliaria credito) throws DocumentException { documento.add(foto);/*ww w . j av a 2s . co m*/ Paragraph p = new Paragraph("BUFETE DEL RIO, S.C.", tituloN1); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("La Firma Marca la Diferencia ", tituloN2); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("Balboa 1111, Portales Sur, 03300, Mxico, D.F.", tituloN3); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("(55) 5539 0104 con 10 Lneas contacto@corporativodelrio.com", tituloN3); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); PdfPTable datos = new PdfPTable(2); datos.setWidthPercentage(90); Phrase pnombre = new Phrase(credito.getNombre()); pnombre.setFont(cuerpo2); Phrase pcalle = new Phrase(credito.getCalle()); pcalle.setFont(cuerpo2); Phrase pnumcredito = new Phrase(credito.getNumcredito()); pnumcredito.setFont(cuerpo2); Phrase pcolonia = new Phrase(credito.getColonia()); pcolonia.setFont(cuerpo2); Phrase pdelegacion = new Phrase(credito.getDelegacion()); pdelegacion.setFont(cuerpo2); float sdo = credito.getSaldo(); Phrase psaldo = new Paragraph(nf.format(sdo)); psaldo.setFont(cuerpo2); Phrase pestadpCp = new Phrase(credito.getEstado() + " " + credito.getCp()); pestadpCp.setFont(cuerpo2); PdfPCell nombre = new PdfPCell(pnombre); PdfPCell titulocred = new PdfPCell(new Phrase("N Crdito")); PdfPCell calle = new PdfPCell(pcalle); PdfPCell numcredito = new PdfPCell(pnumcredito); PdfPCell colonia = new PdfPCell(pcolonia); PdfPCell titulosaldo = new PdfPCell(new Phrase("Saldo Vencido")); PdfPCell deleg = new PdfPCell(pdelegacion); PdfPCell saldo = new PdfPCell(psaldo); PdfPCell ciudadCP = new PdfPCell(pestadpCp); PdfPCell blanco = new PdfPCell(new Phrase(" ")); nombre.setBorder(Rectangle.NO_BORDER); titulocred.setBorder(Rectangle.NO_BORDER); titulocred.setHorizontalAlignment(Chunk.ALIGN_RIGHT); calle.setBorder(Rectangle.NO_BORDER); numcredito.setBorder(Rectangle.NO_BORDER); numcredito.setHorizontalAlignment(Chunk.ALIGN_RIGHT); colonia.setBorder(Rectangle.NO_BORDER); titulosaldo.setBorder(Rectangle.NO_BORDER); titulosaldo.setHorizontalAlignment(Chunk.ALIGN_RIGHT); deleg.setBorder(Rectangle.NO_BORDER); saldo.setBorder(Rectangle.NO_BORDER); saldo.setHorizontalAlignment(Chunk.ALIGN_RIGHT); ciudadCP.setBorder(Rectangle.NO_BORDER); blanco.setBorder(Rectangle.NO_BORDER); datos.addCell(nombre); datos.addCell(titulocred); datos.addCell(calle); datos.addCell(numcredito); datos.addCell(colonia); datos.addCell(titulosaldo); datos.addCell(deleg); datos.addCell(saldo); datos.addCell(ciudadCP); datos.addCell(blanco); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(datos); p = new Paragraph("Credito CT Express", tituloN2); p.setAlignment(Chunk.ALIGN_RIGHT); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Srvase la presente, como requerimiento de pago a favor de Inbursa para regularizar su situacin de adeudo que actualmente presenta en la Linea de Crdito CT Express otorgada por Inbursa.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Recuerde que este Crdito se otorg con base en su excelente historial de pago y manejo de su cuenta CT y ahora lo exhortamos a que regularize esta situacin a la brevedad, evitando as, situaciones inconvenientes y daando su buena imagen crediticia.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); p = new Paragraph( "Representamos a Inbursa para que recuperemos los pagos atrasados de la Lnea de Crdito que se otorg.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Invariablemente el pago de lo atrasado, deber hacerse nicamente en la Sucursal de Banco Inbursa de su eleccin, a las siguientes Cuentas:", cuerpo); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph("CUENTA CONCENTRADORA 50015025905 a nombre de Banco Inbursa Cobranza Express PYME \n" + "o mediante SPEI a la Cuenta 036180-50015025905-6\n" + "o bien en Bancomer:\n" + "Convenio CIE 386120 Referencia 50015025902", cuerpo); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("Y no olvide remitirnos el pago de su crdito va correo electrnico.", cuerpoNegritas); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Contamos con sus Pagos y con su Comunicacin donde un asesor de este Corporativo le atender. EN CASO DE QUE REQUIERA PLAZO PARA PAGAR, CONTACTENOS.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph("A T E N T A M E N T E", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph("BUFETE DEL RIO, S.C.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "BUFETE DEL RIO, S.C. una Divisin de CORPORATIVO DEL RIO Y ASOCIADOS S.C.\n" + "AVISO DE PRIVACIDAD. Puede ser consultado en la pgina Web www.corporativodelrio.com", cuerpoMini); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); }
From source file:com.pdfs.GeneradorVisitas.java
public void addCreditosTelmex(DatosVisitaDomiciliaria credito) throws DocumentException { documento.add(foto);/*from w w w. ja v a 2s . co m*/ Paragraph p = new Paragraph("BUFETE DEL RIO, S.C.", tituloN1); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("La Firma Marca la Diferencia ", tituloN2); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("Balboa 1111, Portales Sur, 03300, Mxico, D.F.", tituloN3); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("(55) 5539 0104 con 10 Lneas contacto@corporativodelrio.com", tituloN3); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); PdfPTable datos = new PdfPTable(2); datos.setWidthPercentage(90); Phrase pnombre = new Phrase(credito.getNombre()); pnombre.setFont(cuerpo2); Phrase pcalle = new Phrase(credito.getCalle()); pcalle.setFont(cuerpo2); Phrase pnumcredito = new Phrase(credito.getNumcredito()); pnumcredito.setFont(cuerpo2); Phrase pcolonia = new Phrase(credito.getColonia()); pcolonia.setFont(cuerpo2); Phrase pdelegacion = new Phrase(credito.getDelegacion()); pdelegacion.setFont(cuerpo2); float sdo = credito.getSaldo(); Phrase psaldo = new Paragraph(nf.format(sdo)); psaldo.setFont(cuerpo2); Phrase pestadpCp = new Phrase(credito.getEstado() + " " + credito.getCp()); pestadpCp.setFont(cuerpo2); PdfPCell nombre = new PdfPCell(pnombre); PdfPCell titulocred = new PdfPCell(new Phrase("N Crdito")); PdfPCell calle = new PdfPCell(pcalle); PdfPCell numcredito = new PdfPCell(pnumcredito); PdfPCell colonia = new PdfPCell(pcolonia); PdfPCell titulosaldo = new PdfPCell(new Phrase("Saldo Vencido")); PdfPCell deleg = new PdfPCell(pdelegacion); PdfPCell saldo = new PdfPCell(psaldo); PdfPCell ciudadCP = new PdfPCell(pestadpCp); PdfPCell blanco = new PdfPCell(new Phrase(" ")); nombre.setBorder(Rectangle.NO_BORDER); titulocred.setBorder(Rectangle.NO_BORDER); titulocred.setHorizontalAlignment(Chunk.ALIGN_RIGHT); calle.setBorder(Rectangle.NO_BORDER); numcredito.setBorder(Rectangle.NO_BORDER); numcredito.setHorizontalAlignment(Chunk.ALIGN_RIGHT); colonia.setBorder(Rectangle.NO_BORDER); titulosaldo.setBorder(Rectangle.NO_BORDER); titulosaldo.setHorizontalAlignment(Chunk.ALIGN_RIGHT); deleg.setBorder(Rectangle.NO_BORDER); saldo.setBorder(Rectangle.NO_BORDER); saldo.setHorizontalAlignment(Chunk.ALIGN_RIGHT); ciudadCP.setBorder(Rectangle.NO_BORDER); blanco.setBorder(Rectangle.NO_BORDER); datos.addCell(nombre); datos.addCell(titulocred); datos.addCell(calle); datos.addCell(numcredito); datos.addCell(colonia); datos.addCell(titulosaldo); datos.addCell(deleg); datos.addCell(saldo); datos.addCell(ciudadCP); datos.addCell(blanco); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(datos); p = new Paragraph("Crdito TELMEX", tituloN2); p.setAlignment(Chunk.ALIGN_RIGHT); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Srvase la presente, como requerimiento de pago a favor de Inbursa para regularizar su situacin de adeudo que actualmente presenta en la Linea de Crdito Telmex otorgada por Inbursa.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Recuerde que este Crdito se otorg con base en su excelente historial de pago puntual de su Lnea Telmex y ahora lo exhortamos a que regularize esta situacin a la brevedad, evitando situaciones inconvenientes y daando su buena imagen crediticia.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); p = new Paragraph( "Representamos a Inbursa para que recuperemos los pagos atrasados de la Lnea de Crdito que se otorg.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Invariablemente el pago de lo atrasado, deber hacerse nicamente en la Sucursal de Banco Inbursa de su eleccin, a las siguientes Cuentas:", cuerpo); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph("CUENTA CONCENTRADORA 50015025745 a nombre de Banco Inbursa Cobranza Telmex\n" + "o mediante SPEI a la Cuenta 036180-50015025745-6\n" + "o bien en Bancomer:\n" + "Convenio CIE 386120 Referencia 50015025741", cuerpo); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); p = new Paragraph("Y no olvide remitirnos el pago de su crdito va correo electrnico.", cuerpoNegritas); p.setAlignment(Chunk.ALIGN_CENTER); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "Contamos con sus Pagos y con su Comunicacin donde un asesor de este Corporativo le atender. EN CASO DE QUE REQUIERA PLAZO PARA PAGAR, CONTACTENOS.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph("A T E N T A M E N T E", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph("BUFETE DEL RIO, S.C.", cuerpo); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); documento.add(new Paragraph(Chunk.NEWLINE)); p = new Paragraph( "BUFETE DEL RIO, S.C. una Divisin de CORPORATIVO DEL RIO Y ASOCIADOS S.C.\n" + "AVISO DE PRIVACIDAD. Puede ser consultado en la pgina Web www.corporativodelrio.com", cuerpoMini); p.setAlignment(Chunk.ALIGN_JUSTIFIED); documento.add(p); }