List of usage examples for com.itextpdf.text Chunk Chunk
private Chunk(final Float tabInterval, final boolean isWhitespace)
From source file:com.devox.GUI.PDF.ExportarAPDF.java
private static PdfPTable setUpInformation() { PdfPTable table = new PdfPTable(2); try {/*from www . ja v a 2s. c o m*/ PdfPCell cell; Phrase folio = new Phrase(); folio.add(new Chunk("FOLIO DHL ", font_foliodhl)); folio.add(new Chunk(contenido.getFolioDHL(), font_folionum)); cell = new PdfPCell(folio); cell.setRowspan(8); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("Cliente ", contenido.getNombreCliente())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("Nmero de cliente ", contenido.getClaveCliente())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("Folio del cliente ", contenido.getFolioCliente())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("Folio Abbott ", contenido.getFolioAbbott())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("Motivo de devolucin ", contenido.getMotivo().getCodigo() + " - " + contenido.getMotivo().getDescripcion())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("Factura ", contenido.getFactura())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("Almacn ", contenido.getAlmacen())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell( getPhraseFromChunks("Fecha de captura ", Funciones.getOtherDate(contenido.getFechaCaptura()))); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); table.setWidthPercentage(100); table.setWidths(new int[] { 1, 3 }); } catch (DocumentException ex) { Log.print(ex); Log.print(ex); } return table; }
From source file:com.devox.GUI.PDF.ExportarAPDF.java
private PdfPTable setUpInformationTarimas() { PdfPTable table = new PdfPTable(2); try {// ww w . j a va 2 s. com PdfPCell cell; Phrase tarima = new Phrase(); tarima.add(new Chunk("TARIMA\n", font_tarimota)); tarima.add(new Chunk(datosTarima.getNombreTarima(), font_tarimota_gris)); cell = new PdfPCell(tarima); cell.setRowspan(5); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); cell.setFixedHeight(200f); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("DIVISIN ", datosTarima.getDivision())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("ALMACN ", datosTarima.getAlmacen())); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("FECHA DE APERTURA ", Funciones.getOtherDate(datosTarima.getFecha_Apertura()))); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell( getPhraseFromChunks("FECHA DE CIERRE ", Funciones.getOtherDate(datosTarima.getFecha_Cierra()))); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); cell = new PdfPCell(getPhraseFromChunks("DESTRUCCIN FISCAL ", Integer.toString(datosTarima.getDestruccionFiscal()))); cell.setBorder(PdfPCell.NO_BORDER); cell.setPaddingLeft(40); table.addCell(cell); table.setWidthPercentage(100); table.setWidths(new int[] { 2, 1 }); } catch (DocumentException de) { Log.print(de); } return table; }
From source file:com.devox.GUI.PDF.ExportarAPDF.java
private static Phrase getPhraseFromChunks(String a, String b) { Phrase phrase = new Phrase(); phrase.add(new Chunk(a, font_info)); phrase.add(new Chunk(b, font_datos)); return phrase; }
From source file:com.gadroves.gsisinve.controller.FacturarController.java
void PrintToPDF(TbFacturaVenta facturaVenta, TbCLienteFactura cLienteFactura) throws DocumentException, IOException { Font header = new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD); Font normalBold = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD); Font normal = new Font(Font.FontFamily.HELVETICA, 12); String fileName = "Factura_" + facturaVenta.getId() + ".pdf"; // step 1// w w w . ja va 2 s .c om Document document = new Document(); // step 2 PdfWriter.getInstance(document, new FileOutputStream(fileName)); // step 3 document.open(); // step 4 document.add(new Paragraph("Gadroves S.A Factura De Venta", header)); document.add(new Paragraph(" ")); document.add(new Paragraph("Factura N" + facturaVenta.getId(), normalBold)); document.add(new Chunk("Cliente: ", normalBold)); document.add(new Chunk(" ")); document.add(new Chunk(cLienteFactura.getName(), normal)); document.add(new Paragraph()); document.add(new Chunk("Direccin: ", normalBold)); document.add(new Chunk(" ")); document.add(new Chunk(cLienteFactura.getAddress(), normal)); document.add(new Paragraph()); document.add(new Chunk("Identificacion: ", normalBold)); document.add(new Chunk(" ")); document.add(new Chunk(cLienteFactura.getId(), normal)); document.add(new Paragraph()); document.add(new Chunk("Credito: ", normalBold)); document.add(new Chunk(" ")); document.add(new Chunk(Boolean.FALSE.toString(), normal)); document.add(new Paragraph()); for (int i = 0; i < 3; i++) document.add(new Paragraph(" ")); createItemsTable(document, facturaVenta); document.add(new Paragraph(" ")); Paragraph subs = new Paragraph(); subs.setAlignment(Element.ALIGN_RIGHT); subs.setIndentationRight(40); subs.add(new Chunk("Subtotal: " + String.format("%1$" + 10 + "s", String.valueOf(facturaVenta.getSub())))); subs.add(Chunk.NEWLINE); subs.add(new Chunk( "Impuestos: " + String.format("%1$" + 10 + "s", String.valueOf(facturaVenta.getImpuestos())))); subs.add(Chunk.NEWLINE); subs.add(new Chunk( "Total: " + String.format("%1$" + 10 + "s", String.valueOf(facturaVenta.getTotal())))); subs.add(Chunk.NEWLINE); document.add(subs); // step 5 document.close(); Desktop.getDesktop().open(new File(fileName)); }
From source file:com.gp.cong.logisoft.lcl.report.LclVoyageNotificationPdfCreator.java
public PdfPTable dispoInfo(LclUnitSs lclUnitSs) throws DocumentException, Exception { Paragraph pHeading = null;/* www .j a v a 2 s.co m*/ table = new PdfPTable(1); table.setWidthPercentage(100f); PdfPCell cell1 = null; cell1 = new PdfPCell(); cell1.setBorder(0); cell1.setBorderColor(new BaseColor(00, 51, 153)); cell1.setBorderWidthBottom(3f); cell1.setBorderWidthLeft(3f); cell1.setBorderWidthRight(3f); cell1.setBorderWidthTop(10f); cell1.setPadding(0f); //Heading pHeading = new Paragraph(8f, "Disposition Details", mainHeadingQuote); pHeading.setAlignment(Element.ALIGN_CENTER); cell1.addElement(pHeading); //company Name PdfPTable ntable1 = new PdfPTable(9); ntable1.setWidthPercentage(100f); ntable1.setWidths(new float[] { 0.2f, 2f, 0.25f, 1.5f, 0.25f, 4.5f, 1.5f, 5f, .5f }); ntable1.addCell(createEmptyCell(0, 0.1f, 9)); ntable1.addCell(createEmptyCell(0, 1f, 0)); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthBottom(0.06f); Chunk c1 = new Chunk("DATE", greenCourierFont9); cell.addElement(c1); ntable1.addCell(cell); ntable1.addCell(createEmptyCell(0, .5f, 0)); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthBottom(0.06f); c1 = new Chunk("TIME", greenCourierFont9); cell.addElement(c1); ntable1.addCell(cell); ntable1.addCell(createEmptyCell(0, .5f, 0)); cell = new PdfPCell(); cell.setBorder(0); cell.setBorderWidthBottom(0.06f); c1 = new Chunk("CONTAINER STATUS", greenCourierFont9); cell.addElement(c1); ntable1.addCell(cell); ntable1.addCell(createEmptyCell(0, .5f, 0)); ntable1.addCell(createEmptyCell(0, .5f, 0)); ntable1.addCell(createEmptyCell(0, .5f, 0)); LclSsDetail lclSsDetail = lclUnitSs.getLclSsHeader().getVesselSsDetail(); List<LclUnitSsDispo> dispositionList = new LclUnitSsDispoDAO() .getUnitDispoDetailsWithoutData(lclUnitSs.getLclUnit().getId(), lclSsDetail.getId()); if (!dispositionList.isEmpty()) { for (int i = 0; i < dispositionList.size(); i++) { LclUnitSsDispo lclUnitSsDispo = (LclUnitSsDispo) dispositionList.get(i); String dateTimeV = DateUtils.formatDate(lclUnitSsDispo.getDispositionDatetime(), "dd-MMM-yyyy hh:mm a"); String[] dateTimeArray1 = dateTimeV.split(" "); ntable1.addCell(createEmptyCell(0, 1f, 0)); cell = new PdfPCell(); cell.setBorder(0); pHeading = new Paragraph(5f, "" + dateTimeArray1[0], greenCourierFont9); cell.addElement(pHeading); ntable1.addCell(cell); ntable1.addCell(createEmptyCell(0, .5f, 0)); cell = new PdfPCell(); cell.setBorder(0); pHeading = new Paragraph(5f, "" + dateTimeArray1[1] + " " + dateTimeArray1[2], greenCourierFont9); cell.addElement(pHeading); ntable1.addCell(cell); ntable1.addCell(createEmptyCell(0, .5f, 0)); cell = new PdfPCell(); cell.setBorder(0); if (lclUnitSsDispo.getDisposition() != null && lclUnitSsDispo.getDisposition().getDescription() != null) { pHeading = new Paragraph(5f, "" + lclUnitSsDispo.getDisposition().getDescription(), greenCourierFont9); } else { pHeading = new Paragraph(5f, "" + lclUnitSsDispo.getDisposition().getEliteCode(), greenCourierFont9); } cell.addElement(pHeading); ntable1.addCell(cell); ntable1.addCell(createEmptyCell(0, .5f, 0)); ntable1.addCell(createEmptyCell(0, .5f, 0)); ntable1.addCell(createEmptyCell(0, .5f, 0)); } } ntable1.addCell(createEmptyCell(0, 2f, 9)); cell1.addElement(ntable1); table.addCell(cell1); return table; }
From source file:com.hrms.struts.Reportsaction.java
public String employeePdf() { HttpServletResponse res = ServletActionContext.getResponse(); Rectangle envelope = new Rectangle(1300, 1300); Document d = new Document(envelope, 10f, 10f, 100f, 0f); ByteArrayOutputStream b = new ByteArrayOutputStream(); d.addTitle("Salary Abstract For the Month of JUNE 2016"); Font ffont = new Font(Font.FontFamily.TIMES_ROMAN, 25, Font.BOLD); try {//from w w w .j a va 2s . c om String date = object.getEmpdate(); System.out.println("ssdff" + date); SimpleDateFormat s1 = new SimpleDateFormat("dd-MM-yy"); Date d1 = s1.parse(date); System.out.println("Date is [[[[[[[[[[[[[[[" + d1); Calendar cal = Calendar.getInstance(); cal.setTime(d1); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH) + 1; System.out.println("Incentives year year isssssssss" + year); String[] monthNames = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; String newmonth = monthNames[month - 1]; Chunk reportTitle = new Chunk("Pay Sheet For the Month of " + newmonth + year, ffont); Phrase p = new Phrase(reportTitle); // p.add(reportTitle); Paragraph para = new Paragraph(); para.add(p); para.setAlignment(Element.ALIGN_CENTER); PdfWriter.getInstance(d, b); Font boldFont = new Font(Font.FontFamily.TIMES_ROMAN, 15, Font.BOLD); // Phrase zzz=new Phrase("S. No",boldFont); Phrase one = new Phrase("Dept Name", boldFont); Phrase two = new Phrase("Days", boldFont); Phrase five = new Phrase("Wage", boldFont); Phrase four = new Phrase("Earn", boldFont); Phrase three = new Phrase("Inc", boldFont); Phrase six = new Phrase("Gross Salary", boldFont); Phrase seven = new Phrase("PF", boldFont); Phrase seven2 = new Phrase("Salary Advance", boldFont); Phrase eight = new Phrase("Cash Loan", boldFont); Phrase nine = new Phrase("Gas Loan", boldFont); Phrase ten = new Phrase("Tra Loan", boldFont); Phrase ten4 = new Phrase("Power", boldFont); Phrase ten5 = new Phrase("Meals", boldFont); Phrase ten6 = new Phrase("Tiffin", boldFont); Phrase ten7 = new Phrase("Tea", boldFont); Phrase ten8 = new Phrase("Store", boldFont); Phrase ten9 = new Phrase("Medicines", boldFont); Phrase ten11 = new Phrase("Cable", boldFont); Phrase one1 = new Phrase("Gas", boldFont); Phrase two1 = new Phrase("Adv2", boldFont); Phrase five1 = new Phrase("Eggs", boldFont); Phrase four1 = new Phrase("Uniform", boldFont); Phrase three1 = new Phrase("Total Deductions", boldFont); Phrase six1 = new Phrase("Net Salary", boldFont); // PdfPCell pdfWordCel1zz= new PdfPCell(); PdfPCell pdfWordCell1 = new PdfPCell(); PdfPCell pdfWordCell2 = new PdfPCell(); PdfPCell pdfWordCell3 = new PdfPCell(); PdfPCell pdfWordCell4 = new PdfPCell(); PdfPCell pdfWordCell5 = new PdfPCell(); PdfPCell pdfWordCell6 = new PdfPCell(); PdfPCell pdfWordCell7 = new PdfPCell(); PdfPCell pdfWordCell8 = new PdfPCell(); PdfPCell pdfWordCell9 = new PdfPCell(); PdfPCell pdfWordCell10 = new PdfPCell(); PdfPCell pdfWordCell11 = new PdfPCell(); PdfPCell pdfWordCell12 = new PdfPCell(); PdfPCell pdfWordCell13 = new PdfPCell(); PdfPCell pdfWordCell14 = new PdfPCell(); PdfPCell pdfWordCell15 = new PdfPCell(); PdfPCell pdfWordCell16 = new PdfPCell(); PdfPCell pdfWordCell17 = new PdfPCell(); PdfPCell pdfWordCell18 = new PdfPCell(); PdfPCell pdfWordCell19 = new PdfPCell(); PdfPCell pdfWordCell20 = new PdfPCell(); PdfPCell pdfWordCell21 = new PdfPCell(); PdfPCell pdfWordCell22 = new PdfPCell(); PdfPCell pdfWordCell23 = new PdfPCell(); PdfPCell pdfWordCell24 = new PdfPCell(); // pdfWordCel1zz.addElement(zzz); pdfWordCell1.addElement(one); pdfWordCell2.addElement(two); pdfWordCell3.addElement(five); pdfWordCell4.addElement(four); pdfWordCell5.addElement(three); pdfWordCell6.addElement(six); pdfWordCell7.addElement(seven); pdfWordCell8.addElement(seven2); pdfWordCell9.addElement(eight); pdfWordCell10.addElement(nine); pdfWordCell11.addElement(ten); pdfWordCell12.addElement(ten4); pdfWordCell13.addElement(ten5); pdfWordCell14.addElement(ten6); pdfWordCell15.addElement(ten7); pdfWordCell16.addElement(ten8); pdfWordCell17.addElement(ten9); pdfWordCell18.addElement(ten11); pdfWordCell19.addElement(one1); pdfWordCell20.addElement(two1); pdfWordCell21.addElement(five1); pdfWordCell22.addElement(four1); pdfWordCell23.addElement(three1); pdfWordCell24.addElement(six1); d.open(); PdfPTable table = new PdfPTable(24); table.setTotalWidth(1250); //table.setWidths(new int[] {40,40}); table.setLockedWidth(true); // table.addCell( pdfWordCel1zz ); table.addCell(pdfWordCell1); table.addCell(pdfWordCell2); table.addCell(pdfWordCell3); table.addCell(pdfWordCell4); table.addCell(pdfWordCell5); table.addCell(pdfWordCell6); table.addCell(pdfWordCell7); table.addCell(pdfWordCell8); table.addCell(pdfWordCell9); table.addCell(pdfWordCell10); table.addCell(pdfWordCell11); table.addCell(pdfWordCell12); table.addCell(pdfWordCell13); table.addCell(pdfWordCell14); table.addCell(pdfWordCell15); table.addCell(pdfWordCell16); table.addCell(pdfWordCell17); table.addCell(pdfWordCell18); table.addCell(pdfWordCell19); table.addCell(pdfWordCell20); table.addCell(pdfWordCell21); table.addCell(pdfWordCell22); table.addCell(pdfWordCell23); table.addCell(pdfWordCell24); Connection connection = null; Class.forName("com.mysql.jdbc.Driver"); connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/hrmsdp_10", "root", "nivriti@123"); Statement st = connection.createStatement(); CallableStatement st1 = null; String sql = "{Call deptwise1(?,?)}"; st1 = connection.prepareCall(sql); st1.setString(1, newmonth); st1.setInt(2, year); int days2 = 0; int wage2 = 0; int earn2 = 0; int inc2 = 0; int gross2 = 0; int pf2 = 0; int sal_adv2 = 0; int cash2 = 0; int gasl2 = 0; int tra2 = 0; int power2 = 0; int meals2 = 0; int tiffin2 = 0; int tea2 = 0; int store2 = 0; int medi2 = 0; int cable2 = 0; int gas22 = 0; int adv22 = 0; int eggs2 = 0; int unif2 = 0; int tot_ded2 = 0; int net_sal2 = 0; ResultSet rs = st1.executeQuery(); while (rs.next()) { table.addCell(rs.getString("dept_name")); table.addCell(rs.getString("sum(distinct days)")); table.addCell(rs.getString("wages")); table.addCell(rs.getString("earnings")); table.addCell(rs.getString("increments")); table.addCell(rs.getString("gross_salary")); table.addCell(rs.getString("pf")); table.addCell(rs.getString("salary_advance")); table.addCell(rs.getString("cash_loan")); table.addCell(rs.getString("gas_loan")); table.addCell(rs.getString("tra_loan")); table.addCell(rs.getString("power")); table.addCell(rs.getString("meals")); table.addCell(rs.getString("tiffin")); table.addCell(rs.getString("tea")); table.addCell(rs.getString("store")); table.addCell(rs.getString("medicines")); table.addCell(rs.getString("cable")); table.addCell(rs.getString("gas")); table.addCell(rs.getString("adv2")); table.addCell(rs.getString("eggs")); table.addCell(rs.getString("uniform")); table.addCell(rs.getString("total_deductions")); table.addCell(rs.getString("net_salary")); String days = rs.getString("sum(distinct days)"); String wage = rs.getString("wages"); int wage1 = Integer.parseInt(wage); String earn = (rs.getString("earnings")); int earn1 = Integer.parseInt(earn); String inc = rs.getString("increments"); int inc1 = Integer.parseInt(inc); String gross_sal = rs.getString("gross_salary"); int gross_sal1 = Integer.parseInt(gross_sal); String pf = rs.getString("pf"); int pf1 = Integer.parseInt(pf); String sal_adv = rs.getString("salary_advance"); int sal_adv1 = Integer.parseInt(sal_adv); int cash1 = 0, gas1 = 0, tra1 = 0; try { String cash = rs.getString("cash_loan"); cash1 = Integer.parseInt(cash); System.out.println("Incentives month isssssssss" + newmonth); String gas12 = rs.getString("gas_loan"); gas1 = Integer.parseInt(gas12); String tra = rs.getString("tra_loan"); tra1 = Integer.parseInt(tra); } catch (NumberFormatException nm) { System.out.println("------------------------>" + nm); } String power = rs.getString("power"); int power1 = Integer.parseInt(power); String meals = rs.getString("meals"); int meals1 = Integer.parseInt(meals); String tiffin = rs.getString("tiffin"); int tiffin1 = Integer.parseInt(tiffin); String tea = rs.getString("tea"); int tea1 = Integer.parseInt(tea); String store = rs.getString("store"); int store1 = Integer.parseInt(store); String medicines = rs.getString("medicines"); int medicines1 = Integer.parseInt(medicines); String cable = rs.getString("cable"); int cable1 = Integer.parseInt(cable); String gas2 = rs.getString("gas"); int gas3 = Integer.parseInt(gas2); String adv2 = rs.getString("adv2"); int adv21 = Integer.parseInt(adv2); String egg = rs.getString("eggs"); int egg1 = Integer.parseInt(egg); String uniform = rs.getString("uniform"); int uniform1 = Integer.parseInt(uniform); String tot = rs.getString("total_deductions"); int tot1 = Integer.parseInt(tot); String net = rs.getString("net_salary"); int net1 = Integer.parseInt(net); int days1 = Integer.parseInt(days); System.out.println("ddddddddddddddddddd" + days1); days2 = days1 + days2; System.out.println("ddddddddddddddddddd" + days2); wage2 = wage1 + wage2; earn2 = earn1 + earn2; inc2 = inc1 + inc2; gross2 = gross_sal1 + gross2; pf2 = pf1 + pf2; sal_adv2 = sal_adv1 + sal_adv2; cash2 = cash1 + cash2; gasl2 = gas1 + gasl2; tra2 = tra1 + tra2; power2 = power1 + power2; meals2 = meals1 + meals2; tiffin2 = tiffin1 + tiffin2; tea2 = tea1 + tea2; store2 = store1 + store2; medi2 = medicines1 + medi2; cable2 = cable1 + cable2; gas22 = gas3 + gas22; adv22 = adv21 + adv22; eggs2 = egg1 + eggs2; unif2 = uniform1 + unif2; tot_ded2 = tot1 + tot_ded2; net_sal2 = net1 + net_sal2; } String days3 = Integer.toString(days2); String wage3 = Integer.toString(wage2); String earn3 = Integer.toString(earn2); String inc3 = Integer.toString(inc2); String gross3 = Integer.toString(gross2); String pf3 = Integer.toString(pf2); String sal_adv3 = Integer.toString(sal_adv2); String cash3 = Integer.toString(cash2); String gas13 = Integer.toString(gasl2); String tra3 = Integer.toString(tra2); String power3 = Integer.toString(power2); String meals3 = Integer.toString(meals2); String tiffin3 = Integer.toString(tiffin2); String tea3 = Integer.toString(tea2); String store3 = Integer.toString(store2); String medi3 = Integer.toString(medi2); String cable3 = Integer.toString(cable2); String gas33 = Integer.toString(gas22); String adv33 = Integer.toString(adv22); String eggs3 = Integer.toString(eggs2); String unif3 = Integer.toString(unif2); String tot_ded3 = Integer.toString(tot_ded2); String net_sal3 = Integer.toString(net_sal2); PdfPTable table1 = new PdfPTable(24); Phrase total = new Phrase("TOTAL", boldFont); table1.setTotalWidth(1250); table1.setLockedWidth(true); table1.addCell(total); table1.addCell(days3); table1.addCell(wage3); table1.addCell(earn3); table1.addCell(inc3); table1.addCell(gross3); table1.addCell(pf3); table1.addCell(sal_adv3); table1.addCell(cash3); table1.addCell(gas13); table1.addCell(tra3); table1.addCell(power3); table1.addCell(meals3); table1.addCell(tiffin3); table1.addCell(tea3); table1.addCell(store3); table1.addCell(medi3); table1.addCell(cable3); table1.addCell(gas33); table1.addCell(adv33); table1.addCell(eggs3); table1.addCell(unif3); table1.addCell(tot_ded3); table1.addCell(net_sal3); d.add(para); d.add(Chunk.NEWLINE); d.add(Chunk.NEWLINE); d.add(table); d.add(table1); d.close(); } catch (Exception e) { System.out.println(e); } byte[] bytes = null; bytes = b.toByteArray(); res.setContentLength(bytes.length); if (bytes != null) { inputStream = new ByteArrayInputStream(bytes); } return "success"; }
From source file:com.hrms.struts.Reportsaction.java
public String generateemployees() { // System.out.println(pdf.getEmp_id()); // System.out.println(pdf.getName()); HttpServletResponse res = ServletActionContext.getResponse(); Rectangle envelope = new Rectangle(1300, 1300); Document d = new Document(envelope, 10f, 10f, 100f, 0f); ByteArrayOutputStream b = new ByteArrayOutputStream(); d.addTitle("Salary Abstract For the Month of JUNE 2016"); Font ffont = new Font(Font.FontFamily.TIMES_ROMAN, 25, Font.BOLD); try {/*from ww w . ja va 2 s .c o m*/ String date = object.getEmpdate(); System.out.println("ssdff" + date); SimpleDateFormat s1 = new SimpleDateFormat("dd-MM-yy"); Date d1 = s1.parse(date); System.out.println("Date is [[[[[[[[[[[[[[[" + d1); Calendar cal = Calendar.getInstance(); cal.setTime(d1); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH) + 1; System.out.println("Incentives year year isssssssss" + year); String[] monthNames = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; String newmonth = monthNames[month - 1]; System.out.println("Incentives month isssssssss" + newmonth); Chunk reportTitle = new Chunk("Pay Sheet For the Month of " + newmonth + year, ffont); Phrase p = new Phrase(reportTitle); // p.add(reportTitle); Paragraph para = new Paragraph(); para.add(p); para.setAlignment(Element.ALIGN_CENTER); PdfWriter.getInstance(d, b); PdfWriter.getInstance(d, b); Font boldFont = new Font(Font.FontFamily.TIMES_ROMAN, 15, Font.BOLD); Phrase two = new Phrase("Code No", boldFont); Phrase three = new Phrase("Name", boldFont); Phrase four = new Phrase("Status", boldFont); Phrase five = new Phrase("Dept", boldFont); Phrase six = new Phrase("Days", boldFont); Phrase seven = new Phrase("Wage", boldFont); Phrase eight = new Phrase("Inc", boldFont); Phrase nine = new Phrase("Earn", boldFont); Phrase ten = new Phrase("Inc Amt", boldFont); Phrase eleven = new Phrase("Gross Earn", boldFont); Phrase twelve = new Phrase("PF", boldFont); Phrase thirteen = new Phrase("PPP", boldFont); Phrase fourteen = new Phrase("PF No", boldFont); Phrase fifteen = new Phrase("Sal Advance", boldFont); PdfPCell pdfWordCell2 = new PdfPCell(); PdfPCell pdfWordCell3 = new PdfPCell(); PdfPCell pdfWordCell4 = new PdfPCell(); PdfPCell pdfWordCell5 = new PdfPCell(); PdfPCell pdfWordCell6 = new PdfPCell(); PdfPCell pdfWordCell7 = new PdfPCell(); PdfPCell pdfWordCell8 = new PdfPCell(); PdfPCell pdfWordCell9 = new PdfPCell(); PdfPCell pdfWordCell10 = new PdfPCell(); PdfPCell pdfWordCell11 = new PdfPCell(); PdfPCell pdfWordCell12 = new PdfPCell(); PdfPCell pdfWordCell13 = new PdfPCell(); PdfPCell pdfWordCell14 = new PdfPCell(); PdfPCell pdfWordCell15 = new PdfPCell(); PdfPCell pdfWordCell50 = new PdfPCell(new Phrase("Gas Loan", boldFont)); PdfPCell pdfWordCell16 = new PdfPCell(new Phrase("Cash Loan", boldFont)); PdfPCell pdfWordCell17 = new PdfPCell(new Phrase("Tra Loan", boldFont)); PdfPCell pdfWordCell18 = new PdfPCell(new Phrase("Power", boldFont)); PdfPCell pdfWordCell19 = new PdfPCell(new Phrase("Meals", boldFont)); PdfPCell pdfWordCell20 = new PdfPCell(new Phrase("Tiffin", boldFont)); PdfPCell pdfWordCell21 = new PdfPCell(new Phrase("Tea", boldFont)); PdfPCell pdfWordCell22 = new PdfPCell(new Phrase("Store", boldFont)); PdfPCell pdfWordCell23 = new PdfPCell(new Phrase("Medicine", boldFont)); PdfPCell pdfWordCell24 = new PdfPCell(new Phrase("Cable", boldFont)); PdfPCell pdfWordCell25 = new PdfPCell(new Phrase("Gas", boldFont)); PdfPCell pdfWordCell26 = new PdfPCell(new Phrase("Adv2", boldFont)); PdfPCell pdfWordCell27 = new PdfPCell(new Phrase("Eggs", boldFont)); PdfPCell pdfWordCell28 = new PdfPCell(new Phrase("Uniform", boldFont)); PdfPCell pdfWordCell29 = new PdfPCell(new Phrase("Total Deduction", boldFont)); PdfPCell pdfWordCell30 = new PdfPCell(new Phrase("Net Salary", boldFont)); // PdfPCell pdfWordCell31= new PdfPCell(new Phrase("Signature", boldFont)); pdfWordCell2.addElement(two); pdfWordCell3.addElement(three); pdfWordCell4.addElement(four); pdfWordCell5.addElement(five); pdfWordCell6.addElement(six); pdfWordCell7.addElement(seven); pdfWordCell8.addElement(eight); pdfWordCell9.addElement(nine); pdfWordCell10.addElement(ten); pdfWordCell11.addElement(eleven); pdfWordCell12.addElement(twelve); pdfWordCell13.addElement(thirteen); pdfWordCell14.addElement(fourteen); pdfWordCell15.addElement(fifteen); d.open(); PdfPTable table = new PdfPTable(30); // PdfPTable table1 = new PdfPTable(2); // table.setWidths(new int[]{4,5,6,5,7,5,5,5,4,7,6,4,4,6,8,7,6,6,6,6,4,5,9,5,4,2,2,2,2,2,2}); table.setTotalWidth(1250); table.setWidths(new int[] { 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 45, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 }); table.setLockedWidth(true); // table.addCell( pdfWordCell ); // table.setTotalWidth(1250); // table.setLockedWidth(true); table.addCell(pdfWordCell2); table.addCell(pdfWordCell3); table.addCell(pdfWordCell4); table.addCell(pdfWordCell5); table.addCell(pdfWordCell6); table.addCell(pdfWordCell7); table.addCell(pdfWordCell8); table.addCell(pdfWordCell9); table.addCell(pdfWordCell10); table.addCell(pdfWordCell11); table.addCell(pdfWordCell12); table.addCell(pdfWordCell13); table.addCell(pdfWordCell14); table.addCell(pdfWordCell15); table.addCell(pdfWordCell50); table.addCell(pdfWordCell16); table.addCell(pdfWordCell17); table.addCell(pdfWordCell18); table.addCell(pdfWordCell19); table.addCell(pdfWordCell20); table.addCell(pdfWordCell21); table.addCell(pdfWordCell22); table.addCell(pdfWordCell23); table.addCell(pdfWordCell24); table.addCell(pdfWordCell25); table.addCell(pdfWordCell26); table.addCell(pdfWordCell27); table.addCell(pdfWordCell28); table.addCell(pdfWordCell29); table.addCell(pdfWordCell30); // table.addCell(pdfWordCell31); Connection connection = null; Class.forName("com.mysql.jdbc.Driver"); connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/hrmsdp_10", "root", "nivriti@123"); // Statement st=connection. createStatement(); Statement st1 = connection.createStatement(); CallableStatement st = null; String sql = "{Call emp_payslip123(?,?)}"; st = connection.prepareCall(sql); st.setString(1, newmonth); st.setInt(2, year); // String sql="Call calc(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; // PreparedStatement st=connection.prepareStatement(sql); // ResultSet rs= st.executeQuery("Call calc(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); ResultSet rs = st.executeQuery(); while (rs.next()) { table.addCell(rs.getString("emp_id")); table.addCell(rs.getString("emp_name")); table.addCell(rs.getString("status")); table.addCell(rs.getString("dept_name")); table.addCell(rs.getString("days")); table.addCell(rs.getString("wage")); table.addCell(rs.getString("inc")); table.addCell(rs.getString("earn")); table.addCell(rs.getString("inc_amount")); table.addCell(rs.getString("gross_salary")); table.addCell(rs.getString("pf")); table.addCell(rs.getString("ppp")); table.addCell(rs.getString("pf_no")); table.addCell(rs.getString("salary_advance")); table.addCell(rs.getString("sum(gas_loan)")); table.addCell(rs.getString("sum(cash_loan)")); table.addCell(rs.getString("sum(tra_loan)")); table.addCell(rs.getString("power")); table.addCell(rs.getString("meals")); table.addCell(rs.getString("tiffin")); table.addCell(rs.getString("tea")); table.addCell(rs.getString("store")); table.addCell(rs.getString("medicines")); table.addCell(rs.getString("cable")); table.addCell(rs.getString("gas")); table.addCell(rs.getString("adv2")); table.addCell(rs.getString("eggs")); table.addCell(rs.getString("uniform")); table.addCell(rs.getString("total_deductions")); table.addCell(rs.getString("net_salary")); // table.addCell(""); // table.addCell(image); } //ResultSet rs1=st1.executeQuery("SELECT sum(days) as days , sum(wage) as wages, sum(earn) as earn ,sum(inc) as inc,sum(gros_earn) as gross_earn,sum(sal_advance) as sal_adv,sum(cash_loan) as cash_loan,sum(gas_loan) as gas_loan,sum(tra_loan) as tra_loan,sum(power) as power,sum(meals) as meals,sum(tiffin) as tiffin,sum(tea) as tea,sum(store) as store,sum(medicines) as medicines,sum(cable) as cable,sum(gas) as gas,sum(adv2) as adv2,sum(eggs) as eggs,sum(uniform) as uniform,sum(total_deduction) as totla_deduction FROM caluclation "); // ResultSet rs1=st1.executeQuery("select sum(days),sum(wage) from caluclation"); // String s1=rs1.getString(1); // table.setTotalWidth(PageSize.LARGE_CROWN_OCTAVO.getWidth()); d.add(para); d.add(Chunk.NEWLINE); d.add(Chunk.NEWLINE); d.add(table); d.close(); } catch (Exception e) { System.out.println(e); } byte[] bytes = null; bytes = b.toByteArray(); res.setContentLength(bytes.length); if (bytes != null) { inputStream = new ByteArrayInputStream(bytes); } return "success"; }
From source file:com.ideationdesignservices.txtbook.pdf.TxtBookPdf.java
public float addConversationPart(ColumnText ct, int column, String dateString, String senderString, String contentString, Bitmap contentBitmap, Boolean isVideo, Boolean isMe) throws DocumentException, MalformedURLException, IOException { float messageWidth = 196.0f; Chunk dateChunk = new Chunk(new StringBuilder(String.valueOf(dateString)) .append(MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR).toString(), this.sansFont6Gray); float dateWidth = dateChunk.getWidthPoint(); Paragraph contentParagraph = new Paragraph(); if (contentString.length() > 0) { Element contentChunk = new Chunk(contentString, this.sansFont9); messageWidth = contentChunk.getWidthPoint(); contentParagraph.add(contentChunk); }// w ww . ja va 2s .c o m if (messageWidth < dateWidth) { messageWidth = dateWidth; } if (messageWidth > MAX_COLUMN_CONTENT_WIDTH) { messageWidth = MAX_COLUMN_CONTENT_WIDTH; dateWidth += 7.0f; } Paragraph dateParagraph = new Paragraph(dateChunk); if (isMe.booleanValue()) { dateParagraph.setAlignment(0); dateParagraph .setIndentationLeft((((BUBBLE_L_WIDTH + messageWidth) + BUBBLE_R_WIDTH) + 7.0f) - dateWidth); } else { dateParagraph.setAlignment(2); dateParagraph .setIndentationRight((((BUBBLE_L_WIDTH + messageWidth) + BUBBLE_R_WIDTH) + 7.0f) - dateWidth); } ct.addElement(dateParagraph); contentParagraph.setExtraParagraphSpace(10.0f); if (contentString.length() > 0) { contentParagraph.setAlignment(0); if (isMe.booleanValue()) { contentParagraph.setIndentationLeft(8.6f); contentParagraph.setIndentationRight(BUBBLE_TEXT_INDENT_ALTERNATE); } else { contentParagraph.setIndentationRight(8.6f); float indentLeft = COLUMN_WIDTH - (BUBBLE_L_WIDTH + messageWidth); if (messageWidth == MAX_COLUMN_CONTENT_WIDTH) { indentLeft += BUBBLE_TEXT_INDENT_ALTERNATE; } contentParagraph.setIndentationLeft(indentLeft); } ct.addElement(contentParagraph); } else if (contentBitmap != null) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); if (isVideo.booleanValue()) { contentBitmap.compress(CompressFormat.PNG, 50, stream); } else { contentBitmap.compress(CompressFormat.JPEG, 50, stream); } Image contentImage = Image.getInstance(stream.toByteArray()); contentImage.scaleToFit(198.0f, 198.0f); if (isVideo.booleanValue()) { contentImage.setCompressionLevel(this.settings.compressionLevel); } contentImage.setSpacingBefore(10.0f); contentImage.setSpacingAfter(10.0f); if (isMe.booleanValue()) { contentImage.setAlignment(1); } else { contentImage.setAlignment(1); } ct.addElement(contentImage); } Paragraph senderParagraph = new Paragraph(new Chunk(senderString, this.sansFont9Gray)); if (!isMe.booleanValue()) { senderParagraph.setAlignment(2); } senderParagraph.setSpacingAfter(BUBBLE_TEXT_INDENT_ALTERNATE); ct.addElement(senderParagraph); return messageWidth; }
From source file:com.ideationdesignservices.txtbook.pdf.TxtBookPdf.java
public void addStorybookPart(Document document, int i, Long date, Long previousDate, String senderString, String previousSenderString, String receiverString, String contentString, Bitmap contentBitmap, Boolean isVideo) throws DocumentException, MalformedURLException, IOException { Paragraph paragraph = new Paragraph(); if (i == 0) { paragraph.add(new Chunk("T", this.serifFont24)); paragraph.add(new Chunk("his story begins", this.serifFont11)); if (!this.settings.useTimestamps.booleanValue()) { paragraph.add(new Chunk(MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR, this.serifFont11)); }/*from w w w. jav a 2 s . c o m*/ } else if (!senderString.equals(previousSenderString)) { document.add(Chunk.NEWLINE); } Boolean dateChanged = Boolean.valueOf(false); if (this.settings.useTimestamps.booleanValue()) { SimpleDateFormat dateFormat; if (i == 0) { dateFormat = new SimpleDateFormat("MMMM dd, yyyy", Locale.US); dateFormat.setTimeZone(TimeZone.getDefault()); paragraph.add(new Chunk(" on " + dateFormat.format(new Date(date.longValue())) + MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR, this.serifFont11)); } else { dateFormat = new SimpleDateFormat("MMMM dd, yyyy", Locale.US); dateFormat.setTimeZone(TimeZone.getDefault()); String dateString = dateFormat.format(new Date(date.longValue())); String previousDateString = PdfObject.NOTHING; if (previousDate != null) { previousDateString = dateFormat.format(new Date(previousDate.longValue())); } if (!previousDateString.equals(dateString)) { dateChanged = Boolean.valueOf(true); document.add(Chunk.NEWLINE); paragraph.add(new Chunk("O", this.serifFont24)); paragraph.add(new Chunk("n " + dateString + MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR, this.serifFont11)); } } } if (i == 0) { paragraph.add(new Chunk("when " + senderString + " texted " + receiverString + ", ", this.serifFont11)); } if (contentString.length() > 0) { Boolean addPhrase = Boolean.valueOf(false); String phrase = null; if (dateChanged.booleanValue()) { paragraph.add(new Chunk(new StringBuilder(String.valueOf(senderString)).append(" texted ") .append(receiverString).append(", ").toString(), this.serifFont11)); } else if (!(i == 0 || dateChanged.booleanValue() || senderString.equals(previousSenderString))) { Boolean isOpening = Boolean .valueOf(this.wasLastPhraseOpening.booleanValue() ? this.generator.nextBoolean() : true); int phraseIdx = this.lastPhraseIdx; if (isOpening.booleanValue() && !this.wasLastPhraseOpening.booleanValue()) { this.lastPhraseIdx = -1; } if (isOpening.booleanValue()) { do { phraseIdx = this.generator.nextInt(this.openings.length); } while (phraseIdx == this.lastPhraseIdx); phrase = this.openings[phraseIdx]; } else { do { phraseIdx = this.generator.nextInt(this.closings.length); } while (phraseIdx == this.lastPhraseIdx); phrase = this.closings[phraseIdx]; } this.lastPhraseIdx = phraseIdx; this.wasLastPhraseOpening = isOpening; phrase = phrase.replace("[speaker]", senderString); addPhrase = Boolean.valueOf(true); } if (addPhrase.booleanValue() && this.wasLastPhraseOpening.booleanValue()) { paragraph.add(new Chunk(phrase, this.serifFont11)); } paragraph.add(new Chunk("\"" + contentString.trim() + "\"", this.serifFont11)); if (addPhrase.booleanValue() && !this.wasLastPhraseOpening.booleanValue()) { paragraph.add(new Chunk(phrase, this.serifFont11)); } document.add(paragraph); } else if (contentBitmap != null) { if (i != 0) { paragraph.add(new Chunk(new StringBuilder(String.valueOf(senderString)).append(" sent ") .append(receiverString).append(":").toString(), this.serifFont11)); document.add(paragraph); document.add(Chunk.NEWLINE); } ByteArrayOutputStream stream = new ByteArrayOutputStream(); if (isVideo.booleanValue()) { contentBitmap.compress(CompressFormat.PNG, 50, stream); } else { contentBitmap.compress(CompressFormat.JPEG, 50, stream); } Image contentImage = Image.getInstance(stream.toByteArray()); contentImage.scaleToFit(445.0f, 195.0f); contentImage.setAlignment(1); if (isVideo.booleanValue()) { contentImage.setCompressionLevel(this.settings.compressionLevel); } document.add(contentImage); document.add(Chunk.NEWLINE); } }
From source file:com.javaPdf.app.GeneradorContrato.java
public static void writePDF() { // Document document = new Document() ; Document document = new Document(PageSize.LETTER, 65, 65, 60, 60); try {/*from w w w. jav a2s .c om*/ /*Font que usaran las palabras destacadas con NEGRITA*/ Font font_negrita = FontFactory.getFont("Times New Roman"); font_negrita.setSize(11); font_negrita.setStyle(Font.BOLD); font_negrita.setFamily(Font.FontFamily.TIMES_ROMAN.toString()); Scanner sc = new Scanner(System.in); Calendar calendarioGragoriano = new GregorianCalendar(12, Calendar.MONTH, 2017); /*Inicializar un objeto de tipo Calendar con un metodo de clase (Static) el cual obtiene una onstancia de la clase puede ser mas sencillo*/ Calendar calendario = Calendar.getInstance(); System.out.println(Calendar.DAY_OF_MONTH); System.out.println(calendario.getTime()); /*Datos ingresados por teclado*/ System.out.println("Ingrese el NOMBRE DEL EMPLEADOR: "); Chunk nombreEmpleador = new Chunk("[EMPLEADOR]", font_negrita); System.out.println("Ingrese el RUT DEL EMPLEADOR: "); Chunk rutEmpleador = new Chunk("xx.xxx.xxx-x", font_negrita); System.out.println("Ingrese el NOMBRE DEL TRABAJADOR: "); // Chunk nombreTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk nombreTrabajador = new Chunk(sc.nextLine(), font_negrita); System.out.println("Ingrese el RUT DEL TRABAJADOR: "); // Chunk rutTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk rutTrabajador = new Chunk(sc.nextLine(), font_negrita); System.out.println("Ingrese la DIRECCIN DEL TRABAJADOR: "); // Chunk direccionTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk direccionTrabajador = new Chunk(sc.nextLine(), font_negrita); System.out.println("Ingrese la COMUNA DEL TRABAJADOR: "); // Chunk comunaTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk comunaTrabajador = new Chunk(sc.nextLine(), font_negrita); System.out.println("Ingrese la FECHA DE NACIMIENTO DEL TRABAJADOR: "); // Chunk fechaNacimientoTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk fechaNacimientoTrabajador = new Chunk(sc.nextLine(), font_negrita); System.out.println("Ingrese el SUELDO QUE TENDRA EL TRABAJADOR: "); // Chunk sueldoTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk sueldoTrabajador = new Chunk(sc.nextLine(), font_negrita); System.out.println("Ingrese la FUNCION QUE TENDRA EL TRABAJADOR: "); // Chunk funcionTrabajador = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk funcionTrabajador = new Chunk(sc.nextLine().toUpperCase(), font_negrita); System.out.println("Ingrese la FECHA DE INICIO DE CONTRATO DEL TRABAJADOR: "); // Chunk fechaInicioContrato = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk fechaInicioContrato = new Chunk(sc.nextLine(), font_negrita); System.out.println("Ingrese la FECHA DE TERMINO DE CONTRATO DEL TRABAJADOR: "); // Chunk fechaTerminoContrato = new Chunk ("DATO DE PRUEBA", font_negrita); Chunk fechaTerminoContrato = new Chunk(sc.nextLine(), font_negrita); /*Clausulas*/ Chunk primero = new Chunk(TEXTOPRIMERO, font_negrita); Chunk segundo = new Chunk(TEXTOSEGUNDO, font_negrita); Chunk tercero = new Chunk(TEXTOTERCERO, font_negrita); Chunk cuarto = new Chunk(TEXTOCUARTO, font_negrita); Chunk quinto = new Chunk(TEXTOQUINTO, font_negrita); Chunk sexto = new Chunk(TEXTOSEXTO, font_negrita); Chunk septimo = new Chunk(TEXTOSEPTIMO, font_negrita); Chunk octavo = new Chunk(TEXTOOCTAVO, font_negrita); Chunk noveno = new Chunk(TEXTONOVENO, font_negrita); // Chunk afp = new Chunk (TEXTONOVENO2, font_negrita); // Chunk salud = new Chunk (TEXTONOVENO4, font_negrita); // Chunk cesantia = new Chunk (TEXTONOVENO6, font_negrita); Chunk decimo = new Chunk(TEXTODECIMO, font_negrita); Chunk undecimo = new Chunk(TEXTOUNDECIMO, font_negrita); // Calendar calendario = Calendar.getInstance(); SimpleDateFormat formateador = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy", new Locale("es")); Date fechaDate = new Date(); Chunk fecha = new Chunk(formateador.format(fechaDate), font_negrita); String path = new File(".").getCanonicalPath(); String FILE_NAME = path + "/CONTRATO " + nombreTrabajador + " RUT " + rutTrabajador + ".pdf"; PdfWriter.getInstance(document, new FileOutputStream(new File(FILE_NAME))); // Image firmaEmpleador = Image.getInstance(path + "/img/firmaEmpleador.png"); // firmaEmpleador.scaleAbsoluteWidth(150f); // firmaEmpleador.scaleAbsoluteHeight(70f); // firmaEmpleador.setAbsolutePosition(70f, 200f); // Image timbreGerencia = Image.getInstance(path + "/img/timbreGerencia.png"); timbreGerencia.scaleAbsoluteWidth(90f); timbreGerencia.scaleAbsoluteHeight(75f); timbreGerencia.setAbsolutePosition(230, 200f); // Image firmaTrabajador = Image.getInstance(path + "/img/firmaTrabajador.png"); firmaTrabajador.scaleAbsoluteWidth(160f); firmaTrabajador.scaleAbsoluteHeight(70f); firmaTrabajador.setAbsolutePosition(350, 175f); // // Image todoEnUno = Image.getInstance(path + "/img/todoEnUno.png"); // todoEnUno.scaleAbsoluteWidth(550); // todoEnUno.scaleAbsoluteHeight(150); // todoEnUno.setAbsolutePosition(15, 120f); document.open(); FontFactory.registerDirectories(); /*Parrafo de Titulo*/ String tituloContrato_texto = "CONTRATO DE TRABAJO:\n"; Font font_titulo = FontFactory.getFont("Times New Roman"); font_titulo.setSize(14); font_titulo.setStyle(Font.BOLD | Font.UNDERLINE); font_titulo.setFamily(Font.FontFamily.TIMES_ROMAN.toString()); Paragraph parrafoTitulo = new Paragraph(tituloContrato_texto, font_titulo); parrafoTitulo.setAlignment(Element.ALIGN_CENTER); document.add(parrafoTitulo); Font font_primer_parrafo = FontFactory.getFont("Times New Roman"); font_primer_parrafo.setSize(11); // font_primer_parrafo.setStyle(Font.BOLD | Font.UNDERLINE); font_primer_parrafo.setFamily(Font.FontFamily.TIMES_ROMAN.toString()); Paragraph primer_parrafo = new Paragraph(); /*Agregar CHunks a el parrafo*/ /*PRIMER PARRAFO*/ primer_parrafo.setAlignment(Element.ALIGN_JUSTIFIED); primer_parrafo.setLeading(15); primer_parrafo.setFont(font_primer_parrafo); primer_parrafo.add(TEXTO1); primer_parrafo.add(fecha); primer_parrafo.add(TEXTO2); primer_parrafo.add(nombreEmpleador); primer_parrafo.add(TEXTO3); primer_parrafo.add(rutEmpleador); primer_parrafo.add(TEXTO4); primer_parrafo.add(nombreTrabajador); primer_parrafo.add(TEXTO5); primer_parrafo.add(rutTrabajador); primer_parrafo.add(TEXTO6); primer_parrafo.add(direccionTrabajador); primer_parrafo.add(TEXTO7); primer_parrafo.add(comunaTrabajador); primer_parrafo.add(TEXTO8); primer_parrafo.add(fechaNacimientoTrabajador); primer_parrafo.add(TEXTO9); /*PRIMERA CLAUSULA*/ primer_parrafo.add(primero); primer_parrafo.add(TEXTOPRIMERO1); primer_parrafo.add(funcionTrabajador); primer_parrafo.add(TEXTOPRIMERO2); /*SEGUNDA CLAUSULA*/ primer_parrafo.add(segundo); // primer_parrafo.add(TEXTOSEGUNDO1); /*TERCERA CLAUSULA*/ primer_parrafo.add(tercero); primer_parrafo.add(TEXTOTERCERO1); primer_parrafo.add(Chunk.TABBING); primer_parrafo.add(TEXTOTERCERO2A); primer_parrafo.add(sueldoTrabajador); primer_parrafo.add(TEXTOTERCERO3A); primer_parrafo.add(Chunk.TABBING); primer_parrafo.add(TEXTOTERCERO4B); /*CUARTA CLAUSULA*/ primer_parrafo.add(cuarto); // primer_parrafo.add(TEXTOCUARTO1); /*QUINTA CLAUSULA*/ primer_parrafo.add(quinto); // primer_parrafo.add(TEXTOQUINTO1); /*SEXTA CLAUSULA*/ primer_parrafo.add(sexto); // primer_parrafo.add(TEXTOSEXTO1); /*SEPTIMA CLAUSULA*/ primer_parrafo.add(septimo); // primer_parrafo.add(TEXTOSEPTIMO1); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO2A); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO3B); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO4C); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO5D); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO6E); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO7F); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO8G); primer_parrafo.add(Chunk.TABBING); // primer_parrafo.add(TEXTOSEPTIMO9H); /*OCTAVA CLAUSULA*/ primer_parrafo.add(octavo); // primer_parrafo.add(TEXTOOCTAVO1); /*NOVENA CLAUSULA*/ primer_parrafo.add(noveno); // primer_parrafo.add(TEXTONOVENO1); // primer_parrafo.add(afp); // primer_parrafo.add(TEXTONOVENO3); // primer_parrafo.add(salud); // primer_parrafo.add(TEXTONOVENO5); // primer_parrafo.add(cesantia); /*public static final String TEXTONOVENO2 = " PROVIDA"; public static final String TEXTONOVENO3 = " Salud:"; public static final String TEXTONOVENO4 = "FONASA"; public static final String TEXTONOVENO5 = ", y las de cesanta en:"; public static final String TEXTONOVENO6 = " AFC. \n\n";*/ /*DCIMA CLAUSULA*/ primer_parrafo.add(decimo); primer_parrafo.add(TEXTODECIMO1); primer_parrafo.add(fechaInicioContrato); primer_parrafo.add(TEXTODECIMO2); primer_parrafo.add(fechaTerminoContrato); primer_parrafo.add(TEXTODECIMO3); /*UNDECIMA CLAUSULA*/ primer_parrafo.add(undecimo); // primer_parrafo.add(TEXTOUNDECIMO1); document.add(primer_parrafo); // document.add(todoEnUno); document.add(timbreGerencia); document.add(firmaTrabajador); document.addAuthor("IGVI"); document.addTitle("CONTRATO DE TRABAJO IGVI"); document.close(); } catch (DocumentException e) { e.getMessage(); } catch (IOException e) { e.getMessage(); } }