List of usage examples for com.lowagie.text.pdf PdfPTable setWidths
public void setWidths(int relativeWidths[]) throws DocumentException
From source file:rollyroll.com.servlet.ModuloServlet.java
private void exportar_ModulosaPDF(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try {//from ww w. j a v a 2 s .c om // String[] headers = new String[]{"CODIGO", "NOMBRE", "ACCION", "ORDEN", "ICONO", "ESTADO"}; String[] headers = new String[] { "NOMBRE", "ACCION", "ICONO" }; ArrayList<Modulo> lista = null; lista = moduloService.listar_Modulos(); PdfPTable table = new PdfPTable(headers.length); table.setHorizontalAlignment(0); table.setWidthPercentage(95); float[] espaciocolumna = new float[] { 25f, 38f, 50f }; table.setWidths(espaciocolumna); for (int i = 0; i < headers.length; i++) { String header = headers[i]; PdfPCell cell = new PdfPCell(); cell.setBackgroundColor(Color.YELLOW); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell.setPhrase(new Phrase(header.toUpperCase(), new Font(Font.HELVETICA, 10, Font.BOLD))); table.addCell(cell); } table.completeRow(); PdfPCell cell; // int codigomodulo = 0; String nombremodulo = ""; String accionmodulo = ""; // int ordenmodulo = 0; String iconomodulo = ""; // int estadomodulo = 0; for (Modulo modulo : lista) { // codigomodulo += Integer.parseInt(modulo.getCodigomodulo()); nombremodulo += modulo.getNombremodulo(); accionmodulo += modulo.getAccionmodulo(); // ordenmodulo += Integer.parseInt(modulo.getOrdenmoduloS()); iconomodulo += modulo.getIconomodulo(); // estadomodulo += Byte.parseByte(modulo.getEstadomoduloS()); // cell = new PdfPCell(); // cell.setPhrase(new Phrase(modulo.getCodigomoduloS(), new Font(Font.HELVETICA, 10, Font.NORMAL))); // cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); // table.addCell(cell); // cell = new PdfPCell(); cell.setPhrase(new Phrase(modulo.getNombremodulo(), new Font(Font.HELVETICA, 10, Font.NORMAL))); cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(); cell.setPhrase(new Phrase(modulo.getAccionmodulo(), new Font(Font.HELVETICA, 10, Font.NORMAL))); cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.addCell(cell); // cell = new PdfPCell(); // cell.setPhrase(new Phrase(modulo.getOrdenmoduloS(), new Font(Font.HELVETICA, 10, Font.NORMAL))); // cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); // table.addCell(cell); cell = new PdfPCell(); cell.setPhrase(new Phrase(modulo.getIconomodulo(), new Font(Font.HELVETICA, 10, Font.NORMAL))); cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); table.addCell(cell); // cell = new PdfPCell(); // cell.setPhrase(new Phrase(modulo.getEstadomoduloS(), new Font(Font.HELVETICA, 10, Font.NORMAL))); // cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); // table.addCell(cell); } table.completeRow(); //incia diseo de documento exportado Document document = new Document(PageSize.A4.rotate(), 20, 5, 5, 5); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open(); document.addTitle("Reporte de Ventas Generales"); document.add( new Paragraph("Reporte: Ventas Generales 2016", new Font(Font.HELVETICA, 16, Font.UNDERLINE))); document.add(new Paragraph("_")); document.add(table); document.add(Chunk.NEWLINE); document.add(new Paragraph( "Leyenda: AB: Inicio, BA: Retorno (Importante: No se consideran unidades sin GPS)")); document.addAuthor("Quispe Roque Alex Christian"); table = new PdfPTable(4); table.setHorizontalAlignment(0); table.setWidthPercentage(40); espaciocolumna = new float[] { 10f, 40f, 20f, 20f }; table.setWidths(espaciocolumna); cell = new PdfPCell(); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cell.setPhrase(new Phrase("RESUMEN", new Font(Font.HELVETICA, 10, Font.BOLD))); cell.setColspan(7); table.addCell(cell); table.completeRow(); //aqui iniciamos asignacion de datos //=================================================================== // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setBackgroundColor(Color.yellow); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("FLOTA OPERATIVA", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase(lista.size() + "", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("UNIDADES", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // table.completeRow(); // // //================================================================================== // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("2", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setBackgroundColor(Color.yellow); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("NRO DE VIAJES", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase((totalAB + totalBA) + "", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // cell = new PdfPCell(); // cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cell.setPhrase(new Phrase("VIAJES", new Font(Font.HELVETICA, 10, Font.BOLD))); // table.addCell(cell); // // table.completeRow(); //================================================================================== document.add(Chunk.NEWLINE); document.add(table); document.left(1); document.top(1); document.close(); response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); // response.setHeader("Content-Disposition", "attachment; filename=ReporteGeneraldeModulos.pdf"); response.setHeader("Content-Disposition", "filename=ReporteGeneraldeModulos.pdf"); response.setHeader("Pragma", "public"); response.setContentType("application/pdf"); response.setContentLength(baos.size()); ServletOutputStream out = response.getOutputStream(); baos.writeTo(out); out.flush(); } catch (Exception e) { RequestDispatcher rd2; rd2 = request.getRequestDispatcher("vista/include/error_404.jsp"); rd2.forward(request, response); System.out.println( "rollyroll.com.servlet.ModuloServlet.exportar_ModulosaPDF() => ERROR GRAVE AL GENERAR PDF"); e.getMessage(); } }
From source file:sms.ReportForms.java
public void utext(String query, String Name, String dob, String house, String formclass, String kcpe, String imgurl, String kcpegrade, String id) { methods nn = new methods(); String u = unig();/* ww w .java 2 s . co m*/ checkPreviousResults(u, kcpe, kcpegrade, id); ArrayList<ExamDbDataHolder> users = selectExamResults(u, query); if (users.size() < 2) { Form1Exams n = new Form1Exams(); String[] Subjects = n.findSubjectid(); String[] Subjectsnames = n.findSubjectname(); JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(",")); chooser.setDialogTitle("Save at"); chooser.setApproveButtonText("save"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { try { Document pdfp = new Document(); PdfWriter w = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(), "" + sid.getText() + ".pdf"))); pdfp.open(); PdfContentByte canvas = w.getDirectContentUnder(); Image imgb = Image.getInstance("C:\\Users\\kimani kogi\\Pictures\\icons\\logo.png"); imgb.setAbsolutePosition(2, 2); imgb.scaleAbsoluteHeight(PageSize.A4.getHeight() / 4); imgb.scaleAbsoluteWidth(PageSize.A4.getWidth() / 4); canvas.saveState(); PdfGState state = new PdfGState(); state.setFillOpacity(0.6f); canvas.setGState(state); canvas.addImage(imgb); canvas.restoreState(); PdfPTable tbl1 = new PdfPTable(2); // tbl.setWidthPercentage(100); tbl1.setTotalWidth(575); tbl1.setLockedWidth(true); tbl1.setWidths(new int[] { 1, 4 }); if (imgurl.equals("image")) { tbl1.addCell("no image "); String img = imgurl; } else { tbl1.addCell(createImageCell(imgurl)); } tbl1.addCell(createTextCell(schooldetails)); PdfPTable tbl = new PdfPTable(8); // tbl.setWidthPercentage(100); tbl.setTotalWidth(575); tbl.setLockedWidth(true); tbl.setSpacingBefore(8); tbl.setSpacingAfter(6); tbl.getDefaultCell().setBorderWidthTop(2); tbl.getDefaultCell().setBorderWidthLeft(0); tbl.getDefaultCell().setBorderWidthRight(0); tbl.setWidths(new int[] { 1, 1, 1, 2, 1, 1, 1, 1 }); tbl.addCell("Adm No:"); tbl.addCell(sid.getText()); tbl.addCell("Name:"); tbl.addCell(Name); tbl.addCell("Form:"); tbl.addCell(formclass); tbl.addCell("Kcpe:"); tbl.addCell(kcpe); tbl.addCell("House:"); tbl.addCell(house); tbl.addCell("Term:"); tbl.addCell("Second term"); tbl.addCell("Year:"); tbl.addCell("2017"); tbl.addCell("DOB:"); tbl.addCell(dob); PdfPTable tbl2 = new PdfPTable(5); // tbl.setWidthPercentage(100); tbl2.setTotalWidth(575); tbl2.setLockedWidth(true); // tbl2.getDefaultCell().setFixedHeight(35f); tbl2.setWidths(new int[] { 2, 1, 1, 2, 2 }); tbl2.addCell(creatTextCellHeader("Subjects")); tbl2.addCell(creatTextCellHeader("Exams")); tbl2.addCell(creatTextCellHeader("Grade")); tbl2.addCell(creatTextCellHeader("Ratings")); tbl2.addCell(creatTextCellHeader("Remarks")); // String [] Subjectsnames=n.findSubjectname(); for (int i = 0; i < users.size(); i++) { for (int a = 0; a < Subjectsnames.length; a++) { tbl2.addCell(Subjectsnames[a]); String re = null; if (Subjects[a].equals("s1")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getMathematics()); re = ((ExamDbDataHolder) users.get(i)).getMathematics(); // JOptionPane.showMessageDialog(null,((ExamDbDataHolder)users.get(i)).getMathematics()); // String maths = ((ExamDbDataHolder)users.get(i)).getMathematics(); } else if (Subjects[a].equals("s2")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getEnglish()); re = ((ExamDbDataHolder) users.get(i)).getEnglish(); //row[c] = ((ExamDbDataHolder)users.get(i)).getEnglish(); // c++; } else if (Subjects[a].equals("s3")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getKiswahili()); re = ((ExamDbDataHolder) users.get(i)).getKiswahili(); // row[c] = ((ExamDbDataHolder)users.get(i)).getKiswahili(); // c++; } else if (Subjects[a].equals("s4")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getPhysics()); re = ((ExamDbDataHolder) users.get(i)).getPhysics(); // row[c] = ((ExamDbDataHolder)users.get(i)).getPhysics(); // c++; } else if (Subjects[a].equals("s5")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getChemistry()); re = ((ExamDbDataHolder) users.get(i)).getChemistry(); // row[c] = ((ExamDbDataHolder)users.get(i)).getChemistry(); // c++; } else if (Subjects[a].equals("s6")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getBiology()); re = ((ExamDbDataHolder) users.get(i)).getBiology(); // row[c] = ((ExamDbDataHolder)users.get(i)).getBiology(); // c++; } else if (Subjects[a].equals("s7")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getHistory()); re = ((ExamDbDataHolder) users.get(i)).getHistory(); // row[c] = ((ExamDbDataHolder)users.get(i)).getHistory(); // c++; } else if (Subjects[a].equals("s8")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getGeography()); re = ((ExamDbDataHolder) users.get(i)).getGeography(); // row[c] = ((ExamDbDataHolder)users.get(i)).getGeography(); // c++; } else if (Subjects[a].equals("s9")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getCre()); re = ((ExamDbDataHolder) users.get(i)).getCre(); // row[c] = ((ExamDbDataHolder)users.get(i)).getCre(); // c++; } else if (Subjects[a].equals("s10")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getIre()); re = ((ExamDbDataHolder) users.get(i)).getIre(); // row[c] = ((ExamDbDataHolder)users.get(i)).getIre(); // c++; } else if (Subjects[a].equals("s11")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getHre()); re = ((ExamDbDataHolder) users.get(i)).getHre(); // row[c] = ((ExamDbDataHolder)users.get(i)).getHre(); // c++; } else if (Subjects[a].equals("s12")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getAgriculture()); re = ((ExamDbDataHolder) users.get(i)).getAgriculture(); // row[c] = ((ExamDbDataHolder)users.get(i)).getAgriculture(); // c++; } else if (Subjects[a].equals("s13")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getHomescience()); re = ((ExamDbDataHolder) users.get(i)).getHomescience(); // row[c] = ((ExamDbDataHolder)users.get(i)).getHomescience(); // c++; } else if (Subjects[a].equals("s14")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getArtdesign()); re = ((ExamDbDataHolder) users.get(i)).getArtdesign(); // row[c] = ((ExamDbDataHolder)users.get(i)).getArtdesign(); // c++; } else if (Subjects[a].equals("s15")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getComputer()); re = ((ExamDbDataHolder) users.get(i)).getComputer(); // row[c] = ((ExamDbDataHolder)users.get(i)).getComputer(); // c++; } else if (Subjects[a].equals("s16")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getBuilding()); re = ((ExamDbDataHolder) users.get(i)).getBuilding(); // row[c] = ((ExamDbDataHolder)users.get(i)).getBuilding(); // c++; } else if (Subjects[a].equals("s17")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getWoodwork()); re = ((ExamDbDataHolder) users.get(i)).getWoodwork(); // row[c] = ((ExamDbDataHolder)users.get(i)).getWoodwork(); // c++; } else if (Subjects[a].equals("s18")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getMetalwork()); re = ((ExamDbDataHolder) users.get(i)).getMetalwork(); // row[c] = ((ExamDbDataHolder)users.get(i)).getMetalwork(); // c++; } else if (Subjects[a].equals("s19")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getMusic()); re = ((ExamDbDataHolder) users.get(i)).getMusic(); // row[c] = ((ExamDbDataHolder)users.get(i)).getMusic(); // c++; } else if (Subjects[a].equals("s20")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getFrench()); re = ((ExamDbDataHolder) users.get(i)).getFrench(); // row[c] = ((ExamDbDataHolder)users.get(i)).getFrench(); // c++; } else if (Subjects[a].equals("s21")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getGerman()); re = ((ExamDbDataHolder) users.get(i)).getGerman(); // row[c] = ((ExamDbDataHolder)users.get(i)).getGerman(); // c++; } else if (Subjects[a].equals("s22")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getArabic()); re = ((ExamDbDataHolder) users.get(i)).getArabic(); // row[c] = ((ExamDbDataHolder)users.get(i)).getArabic(); // c++; } else if (Subjects[a].equals("s23")) { tbl2.addCell(((ExamDbDataHolder) users.get(i)).getBusiness()); re = ((ExamDbDataHolder) users.get(i)).getBusiness(); // row[c] = ((ExamDbDataHolder)users.get(i)).getBusiness(); // c++; } String[] gr = nn.checkGrade(re, Subjects[a]); tbl2.addCell(gr[0]); tbl2.addCell(gr[1]); tbl2.addCell(""); } } //add for all other subjects PdfPTable tbl3 = new PdfPTable(4); // tbl.setWidthPercentage(100); tbl3.setTotalWidth(575); tbl3.setLockedWidth(true); tbl3.setSpacingBefore(8); tbl3.setSpacingAfter(6); // tbl3.getDefaultCell().setBorderWidthTop(0); tbl3.getDefaultCell().setBorder(0); // tbl3.getDefaultCell().setBorderWidthLeft(0); // tbl3.getDefaultCell().setBorderWidthRight(0); tbl3.setWidths(new int[] { 1, 1, 1, 1 }); tbl3.addCell(creatTextCellHeader("CURRENT MARKS:")); tbl3.addCell(creatTextCellHeader(String.valueOf(((ExamDbDataHolder) users.get(0)).getTotal()))); float g = Float.valueOf(((ExamDbDataHolder) users.get(0)).getTotal()); // tbl.addCell(String.format("%.1f", g)); String gr = nn.checkGrade(yearid, String.format("%.1f", g / getYear())); tbl3.addCell(creatTextCellHeader("PREVIOUS MARKS:")); tbl3.addCell(creatTextCellHeader("459")); tbl3.addCell(creatTextCellHeader("AVERAGE MARKS:")); tbl3.addCell(creatTextCellHeader(String.format("%.1f", g / getYear()))); tbl3.addCell(creatTextCellHeader("PREVIOUS AVERAGE:")); tbl3.addCell(creatTextCellHeader("50")); tbl3.addCell(creatTextCellHeader("MEAN GRADE:")); tbl3.addCell(creatTextCellHeader(gr)); tbl3.addCell(creatTextCellHeader("PREVIOUS MEAN GRADE:")); tbl3.addCell(creatTextCellHeader("B")); tbl3.addCell(creatTextCellHeader("POS")); tbl3.addCell(creatTextCellHeader("3 ")); tbl3.addCell(creatTextCellHeader("OUT OF")); tbl3.addCell(creatTextCellHeader("79")); PdfPTable tbl4 = new PdfPTable(2); // tbl.setWidthPercentage(100); tbl4.setHorizontalAlignment(0); //tbl4.HorizontalAlignment=Element.ALIGN_LEFT; tbl4.setTotalWidth(575 / 2); tbl4.setLockedWidth(true); tbl4.setSpacingBefore(8); tbl4.setSpacingAfter(6); // tbl3.getDefaultCell().setBorderWidthTop(0); tbl4.getDefaultCell().setBorder(0); // tbl3.getDefaultCell().setBorderWidthLeft(0); // tbl3.getDefaultCell().setBorderWidthRight(0); tbl4.setWidths(new int[] { 2, 1 }); PdfPCell cell = new PdfPCell(new Paragraph("REMARKS")); cell.setColspan(2); tbl4.addCell(cell); tbl4.addCell(creatTextCellHeader( "CLASS TEACHERS........................................................." + ":............................\n\n\n")); tbl4.addCell(creatTextCellChart("chart")); tbl4.addCell(creatTextCellHeader( "SIGNATURE-------------------------------------------------------------" + "-------------------------------\n\n\n")); tbl4.addCell(creatTextCellHeader( "-------------\n\n\n-----------------------------------------------------------" + "-----------------------------")); pdfp.add(tbl1); pdfp.add(tbl); pdfp.add(tbl2); pdfp.add(tbl3); pdfp.add(tbl4); // Paragraph p=new Paragraph(); // p.setAlignment(Element.ALIGN_CENTER); // p.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD,18,Font.BOLD)); // Paragraph po=new Paragraph(); // po.setAlignment(Element.ALIGN_CENTER); // po.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD,16,Font.BOLD)); // // Paragraph pd=new Paragraph(); // pd.setAlignment(Element.ALIGN_CENTER); // pd.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD,14,Font.BOLD)); // p.add("ITHANGA SECONDARY SCHOOL"); // po.add("PO.BOX 238 ITHANGA THIKA"); // pd.add(new Date().toString()); // pdfp.add(p); // pdfp.add(po); // pdfp.add(pd); // // // // pdfp.add(new Paragraph("\n.................................................................." // + ".................................................................................\n")); // String []names= n.findSubjectname(); // PdfPTable tbl=new PdfPTable(names.length+6); // tbl.setWidths(new float[]{1,1,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1}); // // tbl.setWidthPercentage(100); // tbl.setTotalWidth(575); // tbl.setLockedWidth(true); // PdfPTable tbl1=new PdfPTable(names.length+6); // tbl1.setWidths(new float[]{1,1,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1}); // // tbl.setWidthPercentage(100); // tbl1.setTotalWidth(575); // tbl1.setLockedWidth(true); // PdfPCell cell=new PdfPCell (new Paragraph("RESULTS")); // cell.setColspan((names.length+4)*2); // cell.setBackgroundColor(Color.CYAN); // tbl1.addCell(cell); // tbl1.addCell("Pos"); // tbl1.addCell("id"); // tbl1.addCell("Name"); // int a; pdfp.close(); } catch (Exception j) { j.printStackTrace(); } // Image img=new Image.getInstance("j.png"); } } }
From source file:sms.ViewResults.java
private void itextPrint() { // String searchQuery = "SELECT * FROM `exam` WHERE `yearid` ='" + yearid + "'AND `termid`='"+termid+"'AND `examid`='"+yearid+"'" // + "AND CONCAT(`class`) LIKE '%" + stream + "%'AND YEAR(updated_at)='"+yearchooser.getYear()+"'"; methods nn = new methods(); JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(",")); chooser.setDialogTitle("Save at"); chooser.setApproveButtonText("save"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { try {// w w w .j ava 2 s. c o m Form1Exams n = new Form1Exams(); Document pdfp = new Document(); PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(), "report.pdf"))); pdfp.open(); Paragraph p = new Paragraph(); p.setAlignment(Element.ALIGN_CENTER); p.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD)); Paragraph po = new Paragraph(); po.setAlignment(Element.ALIGN_CENTER); po.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD, 16, Font.BOLD)); Paragraph pd = new Paragraph(); pd.setAlignment(Element.ALIGN_CENTER); pd.setFont(FontFactory.getFont(FontFactory.TIMES_BOLD, 14, Font.BOLD)); p.add("ITHANGA SECONDARY SCHOOL"); po.add("PO.BOX 238 ITHANGA THIKA"); pd.add(new Date().toString()); pdfp.add(p); pdfp.add(po); pdfp.add(pd); pdfp.add(new Paragraph("\n.................................................................." + ".................................................................................\n")); String[] names = n.findSubjectname(); PdfPTable tbl = new PdfPTable(names.length + 6); tbl.setWidths(new float[] { 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }); // tbl.setWidthPercentage(100); tbl.setTotalWidth(575); tbl.setLockedWidth(true); PdfPTable tbl1 = new PdfPTable(names.length + 6); tbl1.setWidths(new float[] { 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }); // tbl.setWidthPercentage(100); tbl1.setTotalWidth(575); tbl1.setLockedWidth(true); PdfPCell cell = new PdfPCell(new Paragraph("RESULTS")); cell.setColspan((names.length + 4) * 2); cell.setBackgroundColor(Color.CYAN); tbl1.addCell(cell); tbl1.addCell("Pos"); tbl1.addCell("id"); tbl1.addCell("Name"); int a; for (a = 0; a < names.length; a++) { String s = names[a]; tbl1.addCell(s.substring(0, Math.min(s.length(), 3))); } tbl1.addCell("Tot"); tbl1.addCell("Ave"); tbl1.addCell("Agg"); pdfp.add(tbl1); try { String[] Subjects = n.findSubjectid(); String[] Subjectsnames = n.findSubjectname(); int subjectCount = Subjects.length; ArrayList<ExamDbDataHolder> users = ListUsers(this.sid.getText()); for (int i = 0; i < users.size(); i++) { tbl.addCell(String.valueOf(i + 1)); String id = ((ExamDbDataHolder) users.get(i)).getSid(); String nam = nn.getStudentName(id); String name = "Eric"; tbl.addCell(id); tbl.addCell(nam); int c = 2; for (int s = 0; s < Subjects.length; s++) { if (Subjects[s].equals("s1")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getMathematics()); // JOptionPane.showMessageDialog(null,((ExamDbDataHolder)users.get(i)).getMathematics()); // String maths = ((ExamDbDataHolder)users.get(i)).getMathematics(); c++; } else if (Subjects[s].equals("s2")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getEnglish()); //row[c] = ((ExamDbDataHolder)users.get(i)).getEnglish(); c++; } else if (Subjects[s].equals("s3")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getKiswahili()); // row[c] = ((ExamDbDataHolder)users.get(i)).getKiswahili(); c++; } else if (Subjects[s].equals("s4")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getPhysics()); // row[c] = ((ExamDbDataHolder)users.get(i)).getPhysics(); c++; } else if (Subjects[s].equals("s5")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getChemistry()); // row[c] = ((ExamDbDataHolder)users.get(i)).getChemistry(); c++; } else if (Subjects[s].equals("s6")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getBiology()); // row[c] = ((ExamDbDataHolder)users.get(i)).getBiology(); c++; } else if (Subjects[s].equals("s7")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getHistory()); // row[c] = ((ExamDbDataHolder)users.get(i)).getHistory(); c++; } else if (Subjects[s].equals("s8")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getGeography()); // row[c] = ((ExamDbDataHolder)users.get(i)).getGeography(); c++; } else if (Subjects[s].equals("s9")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getCre()); // row[c] = ((ExamDbDataHolder)users.get(i)).getCre(); c++; } else if (Subjects[s].equals("s10")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getIre()); // row[c] = ((ExamDbDataHolder)users.get(i)).getIre(); c++; } else if (Subjects[s].equals("s11")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getHre()); // row[c] = ((ExamDbDataHolder)users.get(i)).getHre(); c++; } else if (Subjects[s].equals("s12")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getAgriculture()); // row[c] = ((ExamDbDataHolder)users.get(i)).getAgriculture(); c++; } else if (Subjects[s].equals("s13")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getHomescience()); // row[c] = ((ExamDbDataHolder)users.get(i)).getHomescience(); c++; } else if (Subjects[s].equals("s14")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getArtdesign()); // row[c] = ((ExamDbDataHolder)users.get(i)).getArtdesign(); c++; } else if (Subjects[s].equals("s15")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getComputer()); // row[c] = ((ExamDbDataHolder)users.get(i)).getComputer(); c++; } else if (Subjects[s].equals("s16")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getBuilding()); // row[c] = ((ExamDbDataHolder)users.get(i)).getBuilding(); c++; } else if (Subjects[s].equals("s17")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getWoodwork()); // row[c] = ((ExamDbDataHolder)users.get(i)).getWoodwork(); c++; } else if (Subjects[s].equals("s18")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getMetalwork()); // row[c] = ((ExamDbDataHolder)users.get(i)).getMetalwork(); c++; } else if (Subjects[s].equals("s19")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getMusic()); // row[c] = ((ExamDbDataHolder)users.get(i)).getMusic(); c++; } else if (Subjects[s].equals("s20")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getFrench()); // row[c] = ((ExamDbDataHolder)users.get(i)).getFrench(); c++; } else if (Subjects[s].equals("s21")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getGerman()); // row[c] = ((ExamDbDataHolder)users.get(i)).getGerman(); c++; } else if (Subjects[s].equals("s22")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getArabic()); // row[c] = ((ExamDbDataHolder)users.get(i)).getArabic(); c++; } else if (Subjects[s].equals("s23")) { tbl.addCell(((ExamDbDataHolder) users.get(i)).getBusiness()); // row[c] = ((ExamDbDataHolder)users.get(i)).getBusiness(); c++; } } int tt = ((ExamDbDataHolder) users.get(i)).getTotal(); tbl.addCell(String.valueOf(tt)); float g = Float.valueOf(tt) / 11; tbl.addCell(String.format("%.1f", g)); String gr = nn.checkGrade(yearid, String.format("%.1f", g)); tbl.addCell(gr); } pdfp.add(tbl); } catch (Exception j) { j.printStackTrace(); } pdfp.close(); // Image img=new Image.getInstance("j.png"); } catch (DocumentException ex) { Logger.getLogger(ViewResults.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(ViewResults.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:storemanagment.Printing.java
public final void TransactionGiven(String transactionReceiptNo, String officer, ArrayList<CartPojo> items) { Calendar c = Calendar.getInstance(); Date today = c.getTime();//from w w w . j av a 2s . c om java.util.Date d = (today); java.sql.Date DATE = new java.sql.Date(d.getTime()); // String OrgDetails=res[1]+"\n"+DATE.toString(); String orgDetails[] = getRes(); String orgImg = orgDetails[0]; String orgAbout = orgDetails[1]; JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(",")); chooser.setDialogTitle("Save at"); chooser.setApproveButtonText("save"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { Document pdfp = new Document(); PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream( new File(chooser.getSelectedFile(), transactionReceiptNo + "" + DATE + ".pdf"))); // PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),"Group "+jComboBoxGroup.getSelectedItem().toString()+".pdf"))); HeaderFooterPageEvent event = new HeaderFooterPageEvent(officer, transactionReceiptNo, DATE); writer.setPageEvent(event); pdfp.open(); // Document pdfp=new Document(); // PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),transactionReceiptNo+""+DATE+".pdf"))); // pdfp.open(); PdfPTable header1 = new PdfPTable(1); // // tbl.setWidthPercentage(100); // header1.setTotalWidth(575); header1.setLockedWidth(true); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); PdfPTable header = new PdfPTable(3); // // tbl.setWidthPercentage(100); // header.setTotalWidth(575); header.setLockedWidth(true); header.setWidths(new int[] { 1, 4, 1 }); //THE FIRST ROW //first column ///Logo if (orgImg.equals("image")) { header.addCell("no image "); } else { header.addCell(createImageCell(orgImg)); } //second column ///description header.addCell(createTextCell(orgAbout)); header.addCell(createTextCell("")); PdfPTable RecieptTilte = new PdfPTable(3); // // tbl.setWidthPercentage(100); // RecieptTilte.setTotalWidth(575); RecieptTilte.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptTilte.setWidths(new int[] { 1, 1, 1 }); RecieptTilte.setSpacingBefore(8); RecieptTilte.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptTilte.getDefaultCell().setBorderWidthLeft(0); RecieptTilte.getDefaultCell().setBorderWidthRight(0); RecieptTilte.addCell(""); RecieptTilte.addCell("Transaction Receipt"); RecieptTilte.setSpacingAfter(8); RecieptTilte.addCell(""); PdfPTable RecieptitemsTitles = new PdfPTable(3); RecieptitemsTitles.setTotalWidth(575); RecieptitemsTitles.setWidths(new int[] { 2, 1, 1 }); RecieptitemsTitles.setLockedWidth(true); RecieptitemsTitles.addCell(creatTextCellTitles("Item-Name")); RecieptitemsTitles.addCell(creatTextCellTitles("Quantiy")); RecieptitemsTitles.addCell(creatTextCellTitles("Unit")); // RecieptitemsTitles.addCell(creatTextCellTitles("Id")); // PdfPTable Recieptitems=new PdfPTable(4); for (int a = 0; a < items.size(); a++) { RecieptitemsTitles.addCell(createTextCellcolor(((CartPojo) items.get(a)).getItem_name(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((CartPojo) items.get(a)).getTransaction_quantity(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((CartPojo) items.get(a)).getTransaction_quantity_in(), a)); // RecieptitemsTitles.addCell(createTextCellcolor(String.valueOf(((CartPojo)items.get(a)).getItem_id()),a)); } pdfp.add(header1); pdfp.add(header); pdfp.add(RecieptTilte); pdfp.add(RecieptitemsTitles); pdfp.close(); } catch (DocumentException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } // jComboBoxGroup if (Desktop.isDesktopSupported()) { try { File file = new File(chooser.getSelectedFile(), transactionReceiptNo + "" + DATE + ".pdf"); Desktop.getDesktop().open(file); } catch (Exception ex) { ex.printStackTrace(); } } } }
From source file:storemanagment.Printing.java
public final void TransactionReceived(String transactionReceiptNo, String officer, ArrayList<ReceivedCart> items, String total_cash, String[] otherDetails) { Calendar c = Calendar.getInstance(); Date today = c.getTime();/*from ww w. java 2 s . com*/ java.util.Date d = (today); java.sql.Date DATE = new java.sql.Date(d.getTime()); // String OrgDetails=res[1]+"\n"+DATE.toString(); String orgDetails[] = getRes(); String orgImg = orgDetails[0]; String orgAbout = orgDetails[1]; JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(",")); chooser.setDialogTitle("Save at"); chooser.setApproveButtonText("save"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { Document pdfp = new Document(); PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream( new File(chooser.getSelectedFile(), transactionReceiptNo + "" + DATE + ".pdf"))); // PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),"Group "+jComboBoxGroup.getSelectedItem().toString()+".pdf"))); HeaderFooterPageEvent event = new HeaderFooterPageEvent(officer, transactionReceiptNo, DATE); writer.setPageEvent(event); pdfp.open(); // Document pdfp=new Document(); // PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),transactionReceiptNo+""+DATE+".pdf"))); // pdfp.open(); PdfPTable header1 = new PdfPTable(1); // // tbl.setWidthPercentage(100); // header1.setTotalWidth(575); header1.setLockedWidth(true); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); PdfPTable header = new PdfPTable(3); // // tbl.setWidthPercentage(100); // header.setTotalWidth(575); header.setLockedWidth(true); header.setWidths(new int[] { 1, 4, 1 }); //THE FIRST ROW //first column ///Logo if (orgImg.equals("image")) { header.addCell("no image "); } else { header.addCell(createImageCell(orgImg)); } //second column ///description header.addCell(createTextCell(orgAbout)); header.addCell(createTextCell("")); PdfPTable RecieptTilte = new PdfPTable(3); // // tbl.setWidthPercentage(100); // RecieptTilte.setTotalWidth(575); RecieptTilte.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptTilte.setWidths(new int[] { 1, 1, 1 }); RecieptTilte.setSpacingBefore(8); RecieptTilte.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptTilte.getDefaultCell().setBorderWidthLeft(0); RecieptTilte.getDefaultCell().setBorderWidthRight(0); RecieptTilte.addCell(createTextCellNb("")); RecieptTilte.addCell("GOODS RECEIVED NOTE"); RecieptTilte.setSpacingAfter(8); RecieptTilte.addCell(createTextCellNb("")); PdfPTable RecieptFrom = new PdfPTable(3); // // tbl.setWidthPercentage(100); // RecieptFrom.setTotalWidth(575); RecieptFrom.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptFrom.setWidths(new int[] { 1, 1, 1 }); // RecieptFrom.setSpacingBefore(8); // RecieptFrom.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptFrom.getDefaultCell().setBorderWidthLeft(0); RecieptFrom.getDefaultCell().setBorderWidthRight(0); RecieptFrom.addCell(createTextCellNb("")); RecieptFrom.addCell(createTextCellNb("")); RecieptFrom.addCell(createTextCellNb("")); RecieptFrom.addCell(createTextCellNb("Received From : ")); RecieptFrom.addCell(createTextCellNb(otherDetails[0])); RecieptFrom.addCell(createTextCellNb("")); RecieptFrom.addCell(createTextCellNb("Address :")); RecieptFrom.addCell(createTextCellNb(otherDetails[1])); RecieptFrom.addCell(createTextCellNb("")); RecieptFrom.addCell(createTextCellNb("")); RecieptFrom.addCell(createTextCellNb("")); RecieptFrom.addCell(createTextCellNb("")); // otherDetails[0]=from; // otherDetails[1]=fromAddress; // otherDetails[2]=receivedBy; // otherDetails[3]=designation; // otherDetails[4]=department; // otherDetails[5]=deliveredBy; // otherDetails[6]=reciept_in; PdfPTable RecieptitemsTitles = new PdfPTable(5); RecieptitemsTitles.setTotalWidth(575); RecieptitemsTitles.setWidths(new int[] { 2, 1, 1, 1, 1 }); RecieptitemsTitles.setLockedWidth(true); RecieptitemsTitles.addCell(creatTextCellTitles("Description")); RecieptitemsTitles.addCell(creatTextCellTitles("Quantiy")); RecieptitemsTitles.addCell(creatTextCellTitles("Purchase Order No")); RecieptitemsTitles.addCell(creatTextCellTitles("Rate(Kshs)")); RecieptitemsTitles.addCell(creatTextCellTitles("Value(Kshs)")); // RecieptitemsTitles.addCell(creatTextCellTitles("Id")); // PdfPTable Recieptitems=new PdfPTable(4); for (int a = 0; a < items.size(); a++) { RecieptitemsTitles .addCell(createTextCellcolor(((ReceivedCart) items.get(a)).getItem_name(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((ReceivedCart) items.get(a)).getTransaction_quantity(), a)); RecieptitemsTitles.addCell(createTextCellcolor( ((ReceivedCart) items.get(a)).getTransaction_purchase_order_no(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((ReceivedCart) items.get(a)).getTransaction_item_cash(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((ReceivedCart) items.get(a)).getTransaction_cash(), a)); // RecieptitemsTitles.addCell(createTextCellcolor(String.valueOf(((CartPojo)items.get(a)).getItem_id()),a)); } PdfPTable RecieptTotals = new PdfPTable(4); // // tbl.setWidthPercentage(100); // RecieptTotals.setTotalWidth(575); RecieptTotals.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptTotals.setWidths(new int[] { 1, 1, 1, 1 }); RecieptTotals.setSpacingBefore(8); RecieptTotals.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptTotals.getDefaultCell().setBorderWidthLeft(0); RecieptTotals.getDefaultCell().setBorderWidthRight(0); // otherDetails[2]=receivedBy; // otherDetails[3]=designation; // otherDetails[4]=department; // otherDetails[5]=deliveredBy; // otherDetails[6]=reciept_in; RecieptTotals.addCell(createTextCellNb("")); RecieptTotals.addCell(createTextCellNb("")); RecieptTotals.addCell(createTextCellNb("")); RecieptTotals.addCell(createTextCellNb("")); RecieptTotals.addCell(createTextCellNb("Received By : ")); RecieptTotals.addCell(createTextCellNb(otherDetails[2])); RecieptTotals.addCell(createTextCellNb("Delivered By :")); RecieptTotals.addCell(createTextCellNb(otherDetails[5])); RecieptTotals.addCell(createTextCellNb("Designation : ")); RecieptTotals.addCell(createTextCellNb(otherDetails[3])); RecieptTotals.addCell(createTextCellNb("Total :")); RecieptTotals.addCell(createTextCellNb(total_cash)); RecieptTotals.addCell(createTextCellNb("Department :")); RecieptTotals.addCell(createTextCellNb(otherDetails[4])); RecieptTotals.addCell(createTextCellNb("")); RecieptTotals.addCell(createTextCellNb("")); RecieptTotals.addCell(createTextCellNb("")); RecieptTotals.addCell(createTextCellNb("")); PdfPTable RecieptEnds = new PdfPTable(3); RecieptEnds.setTotalWidth(575); RecieptEnds.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptEnds.setWidths(new int[] { 1, 1, 1 }); RecieptEnds.setSpacingBefore(8); RecieptEnds.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptEnds.getDefaultCell().setBorderWidthLeft(0); RecieptEnds.getDefaultCell().setBorderWidthRight(0); // otherDetails[2]=receivedBy; // otherDetails[3]=designation; // otherDetails[4]=department; // otherDetails[5]=deliveredBy; // otherDetails[6]=reciept_in; RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb("Store Ledger No : ")); RecieptEnds.addCell(createTextCellNb("Invoice No : ")); RecieptEnds.addCell(createTextCellNb("Suppliers Delivery No :")); RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb(transactionReceiptNo)); RecieptEnds.addCell(createTextCellNb(otherDetails[6])); RecieptEnds.addCell(createTextCellNb("-----------------")); RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb("")); RecieptEnds.addCell(createTextCellNb("")); pdfp.add(header1); pdfp.add(header); pdfp.add(RecieptTilte); pdfp.add(RecieptFrom); pdfp.add(RecieptitemsTitles); pdfp.add(RecieptTotals); pdfp.add(RecieptEnds); pdfp.close(); } catch (DocumentException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } // jComboBoxGroup if (Desktop.isDesktopSupported()) { try { File file = new File(chooser.getSelectedFile(), transactionReceiptNo + "" + DATE + ".pdf"); Desktop.getDesktop().open(file); } catch (Exception ex) { ex.printStackTrace(); } } } }
From source file:storemanagment.Printing.java
public final void Inventory(String store, String officer, ArrayList<ItemsPojo> items, String trNo) { Calendar c = Calendar.getInstance(); Date today = c.getTime();//from w ww .j a va 2 s . c om java.util.Date d = (today); java.sql.Date DATE = new java.sql.Date(d.getTime()); // String OrgDetails=res[1]+"\n"+DATE.toString(); String orgDetails[] = getRes(); String orgImg = orgDetails[0]; String orgAbout = orgDetails[1]; JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(",")); chooser.setDialogTitle("Save at"); chooser.setApproveButtonText("save"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { Document pdfp = new Document(); PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(), store + "" + DATE + ".pdf"))); // PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),"Group "+jComboBoxGroup.getSelectedItem().toString()+".pdf"))); HeaderFooterPageEvent event = new HeaderFooterPageEvent(officer, trNo, DATE); writer.setPageEvent(event); pdfp.open(); // Document pdfp=new Document(); // PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),transactionReceiptNo+""+DATE+".pdf"))); // pdfp.open(); PdfPTable header1 = new PdfPTable(1); // // tbl.setWidthPercentage(100); // header1.setTotalWidth(575); header1.setLockedWidth(true); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); PdfPTable header = new PdfPTable(3); // // tbl.setWidthPercentage(100); // header.setTotalWidth(575); header.setLockedWidth(true); header.setWidths(new int[] { 1, 4, 1 }); //THE FIRST ROW //first column ///Logo if (orgImg.equals("image")) { header.addCell("no image "); } else { header.addCell(createImageCell(orgImg)); } //second column ///description header.addCell(createTextCell(orgAbout)); header.addCell(createTextCell("")); PdfPTable RecieptTilte = new PdfPTable(3); // // tbl.setWidthPercentage(100); // RecieptTilte.setTotalWidth(575); RecieptTilte.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptTilte.setWidths(new int[] { 1, 1, 1 }); RecieptTilte.setSpacingBefore(8); RecieptTilte.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptTilte.getDefaultCell().setBorderWidthLeft(0); RecieptTilte.getDefaultCell().setBorderWidthRight(0); RecieptTilte.addCell(""); RecieptTilte.addCell(store + " INVENTORY"); RecieptTilte.setSpacingAfter(8); RecieptTilte.addCell(""); PdfPTable RecieptitemsTitles = new PdfPTable(3); RecieptitemsTitles.setTotalWidth(575); RecieptitemsTitles.setWidths(new int[] { 2, 1, 1 }); RecieptitemsTitles.setLockedWidth(true); RecieptitemsTitles.addCell(creatTextCellTitles("Item-Name")); RecieptitemsTitles.addCell(creatTextCellTitles("Quantiy")); RecieptitemsTitles.addCell(creatTextCellTitles("Unit")); // RecieptitemsTitles.addCell(creatTextCellTitles("Id")); // PdfPTable Recieptitems=new PdfPTable(4); for (int a = 0; a < items.size(); a++) { RecieptitemsTitles.addCell(createTextCellcolor(((ItemsPojo) items.get(a)).getItem_name(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((ItemsPojo) items.get(a)).getItem_quantity(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((ItemsPojo) items.get(a)).getItem_quantity_in(), a)); // RecieptitemsTitles.addCell(createTextCellcolor(String.valueOf(((CartPojo)items.get(a)).getItem_id()),a)); } pdfp.add(header1); pdfp.add(header); pdfp.add(RecieptTilte); pdfp.add(RecieptitemsTitles); pdfp.close(); } catch (DocumentException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } // jComboBoxGroup if (Desktop.isDesktopSupported()) { try { File file = new File(chooser.getSelectedFile(), store + "" + DATE + ".pdf"); Desktop.getDesktop().open(file); } catch (Exception ex) { ex.printStackTrace(); } } } }
From source file:storemanagment.Printing.java
public final void StoreTaking(String store, String officer, ArrayList<ItemsPojo> items) { Calendar c = Calendar.getInstance(); Date today = c.getTime();/*from www. j a v a 2 s . com*/ java.util.Date d = (today); java.sql.Date DATE = new java.sql.Date(d.getTime()); // String OrgDetails=res[1]+"\n"+DATE.toString(); String orgDetails[] = getRes(); String orgImg = orgDetails[0]; String orgAbout = orgDetails[1]; JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(",")); chooser.setDialogTitle("Save at"); chooser.setApproveButtonText("save"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { Document pdfp = new Document(); PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(), store + "" + DATE + ".pdf"))); // PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),"Group "+jComboBoxGroup.getSelectedItem().toString()+".pdf"))); FooterOnly event = new FooterOnly(officer, "", DATE); writer.setPageEvent(event); pdfp.open(); // Document pdfp=new Document(); // PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),transactionReceiptNo+""+DATE+".pdf"))); // pdfp.open(); PdfPTable header1 = new PdfPTable(1); // // tbl.setWidthPercentage(100); // header1.setTotalWidth(575); header1.setLockedWidth(true); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); PdfPTable header = new PdfPTable(3); // // tbl.setWidthPercentage(100); // header.setTotalWidth(575); header.setLockedWidth(true); header.setWidths(new int[] { 1, 4, 1 }); //THE FIRST ROW //first column ///Logo if (orgImg.equals("image")) { header.addCell("no image "); } else { header.addCell(createImageCell(orgImg)); } //second column ///description header.addCell(createTextCell(orgAbout)); header.addCell(createTextCell("")); PdfPTable RecieptTilte = new PdfPTable(3); // // tbl.setWidthPercentage(100); // RecieptTilte.setTotalWidth(575); RecieptTilte.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptTilte.setWidths(new int[] { 1, 1, 1 }); RecieptTilte.setSpacingBefore(8); RecieptTilte.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptTilte.getDefaultCell().setBorderWidthLeft(0); RecieptTilte.getDefaultCell().setBorderWidthRight(0); RecieptTilte.addCell(""); RecieptTilte.addCell(store + " Stock Taking Guide"); RecieptTilte.setSpacingAfter(8); RecieptTilte.addCell(""); PdfPTable RecieptitemsTitles = new PdfPTable(5); RecieptitemsTitles.setTotalWidth(575); RecieptitemsTitles.setWidths(new int[] { 2, 1, 1, 1, 1 }); RecieptitemsTitles.setLockedWidth(true); RecieptitemsTitles.addCell(creatTextCellTitles("Item-Name")); RecieptitemsTitles.addCell(creatTextCellTitles("Quantiy")); RecieptitemsTitles.addCell(creatTextCellTitles("Unit")); RecieptitemsTitles.addCell(creatTextCellTitles("Ph")); RecieptitemsTitles.addCell(creatTextCellTitles("Var")); // RecieptitemsTitles.addCell(creatTextCellTitles("Id")); // PdfPTable Recieptitems=new PdfPTable(4); for (int a = 0; a < items.size(); a++) { RecieptitemsTitles.addCell(createTextCellcolor(((ItemsPojo) items.get(a)).getItem_name(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((ItemsPojo) items.get(a)).getItem_quantity(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((ItemsPojo) items.get(a)).getItem_quantity_in(), a)); RecieptitemsTitles.addCell(createTextCellcolor("", 1)); RecieptitemsTitles.addCell(createTextCellcolor("", 1)); // RecieptitemsTitles.addCell(createTextCellcolor(String.valueOf(((CartPojo)items.get(a)).getItem_id()),a)); } pdfp.add(header1); pdfp.add(header); pdfp.add(RecieptTilte); pdfp.add(RecieptitemsTitles); pdfp.close(); } catch (DocumentException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } // jComboBoxGroup if (Desktop.isDesktopSupported()) { try { File file = new File(chooser.getSelectedFile(), store + "" + DATE + ".pdf"); Desktop.getDesktop().open(file); } catch (Exception ex) { ex.printStackTrace(); } } } }
From source file:storemanagment.Printing.java
public final void Transactions(String store, String officer, ArrayList<TransactionsPojo> items, String trNo) { Calendar c = Calendar.getInstance(); Date today = c.getTime();/*w w w. ja v a2 s . com*/ java.util.Date d = (today); java.sql.Date DATE = new java.sql.Date(d.getTime()); // String OrgDetails=res[1]+"\n"+DATE.toString(); String orgDetails[] = getRes(); String orgImg = orgDetails[0]; String orgAbout = orgDetails[1]; JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(",")); chooser.setDialogTitle("Save at"); chooser.setApproveButtonText("save"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { Document pdfp = new Document(); PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(), store + "tr" + DATE + ".pdf"))); // PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),"Group "+jComboBoxGroup.getSelectedItem().toString()+".pdf"))); HeaderFooterPageEvent event = new HeaderFooterPageEvent(officer, trNo, DATE); writer.setPageEvent(event); pdfp.open(); // Document pdfp=new Document(); // PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),transactionReceiptNo+""+DATE+".pdf"))); // pdfp.open(); PdfPTable header1 = new PdfPTable(1); // // tbl.setWidthPercentage(100); // header1.setTotalWidth(575); header1.setLockedWidth(true); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); PdfPTable header = new PdfPTable(3); // // tbl.setWidthPercentage(100); // header.setTotalWidth(575); header.setLockedWidth(true); header.setWidths(new int[] { 1, 4, 1 }); //THE FIRST ROW //first column ///Logo if (orgImg.equals("image")) { header.addCell("no image "); } else { header.addCell(createImageCell(orgImg)); } //second column ///description header.addCell(createTextCell(orgAbout)); header.addCell(createTextCell("")); PdfPTable RecieptTilte = new PdfPTable(3); // // tbl.setWidthPercentage(100); // RecieptTilte.setTotalWidth(575); RecieptTilte.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptTilte.setWidths(new int[] { 1, 1, 1 }); RecieptTilte.setSpacingBefore(8); RecieptTilte.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptTilte.getDefaultCell().setBorderWidthLeft(0); RecieptTilte.getDefaultCell().setBorderWidthRight(0); RecieptTilte.addCell(""); RecieptTilte.addCell(store + " Transactions"); RecieptTilte.setSpacingAfter(8); RecieptTilte.addCell(""); PdfPTable RecieptitemsTitles = new PdfPTable(9); RecieptitemsTitles.setTotalWidth(575); RecieptitemsTitles.setWidths(new int[] { 1, 1, 2, 1, 1, 1, 1, 1, 2 }); RecieptitemsTitles.setLockedWidth(true); RecieptitemsTitles.addCell(creatTextCellTitles("Item-Name")); RecieptitemsTitles.addCell(creatTextCellTitles("Quantiy")); RecieptitemsTitles.addCell(creatTextCellTitles("Type")); RecieptitemsTitles.addCell(creatTextCellTitles("Unit Rate")); RecieptitemsTitles.addCell(creatTextCellTitles("Total Cash")); RecieptitemsTitles.addCell(creatTextCellTitles("From")); RecieptitemsTitles.addCell(creatTextCellTitles("To")); RecieptitemsTitles.addCell(creatTextCellTitles("R.No")); RecieptitemsTitles.addCell(creatTextCellTitles("Date")); // RecieptitemsTitles.addCell(creatTextCellTitles("Id")); // PdfPTable Recieptitems=new PdfPTable(4); for (int a = 0; a < items.size(); a++) { RecieptitemsTitles .addCell(createTextCellcolor(((TransactionsPojo) items.get(a)).getItem_name(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_quantity() + " " + ((TransactionsPojo) items.get(a)).getTransaction_quantity_in(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_type(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_item_cash(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_cash(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_from(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_to(), a)); RecieptitemsTitles.addCell(createTextCellcolor( ((TransactionsPojo) items.get(a)).getTransaction_receipt_no_out(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_time_string(), a)); // RecieptitemsTitles.addCell(createTextCellcolor(String.valueOf(((CartPojo)items.get(a)).getItem_id()),a)); } pdfp.add(header1); pdfp.add(header); pdfp.add(RecieptTilte); pdfp.add(RecieptitemsTitles); pdfp.close(); } catch (DocumentException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } // jComboBoxGroup if (Desktop.isDesktopSupported()) { try { File file = new File(chooser.getSelectedFile(), store + "tr" + DATE + ".pdf"); Desktop.getDesktop().open(file); } catch (Exception ex) { ex.printStackTrace(); } } } }
From source file:storemanagment.Printing.java
public final void StockTake(String store, String officer, ArrayList<TransactionsPojo> items, String trNo) { Calendar c = Calendar.getInstance(); Date today = c.getTime();//from w w w. ja v a 2 s .c o m java.util.Date d = (today); java.sql.Date DATE = new java.sql.Date(d.getTime()); // String OrgDetails=res[1]+"\n"+DATE.toString(); String orgDetails[] = getRes(); String orgImg = orgDetails[0]; String orgAbout = orgDetails[1]; JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(",")); chooser.setDialogTitle("Save at"); chooser.setApproveButtonText("save"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { try { Document pdfp = new Document(); PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(), store + "st" + DATE + ".pdf"))); // PdfWriter writer = PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),"Group "+jComboBoxGroup.getSelectedItem().toString()+".pdf"))); HeaderFooterPageEvent event = new HeaderFooterPageEvent(officer, trNo, DATE); writer.setPageEvent(event); pdfp.open(); // Document pdfp=new Document(); // PdfWriter.getInstance(pdfp, new FileOutputStream(new File(chooser.getSelectedFile(),transactionReceiptNo+""+DATE+".pdf"))); // pdfp.open(); PdfPTable header1 = new PdfPTable(1); // // tbl.setWidthPercentage(100); // header1.setTotalWidth(575); header1.setLockedWidth(true); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); header1.addCell(createTextCell("")); PdfPTable header = new PdfPTable(3); // // tbl.setWidthPercentage(100); // header.setTotalWidth(575); header.setLockedWidth(true); header.setWidths(new int[] { 1, 4, 1 }); //THE FIRST ROW //first column ///Logo if (orgImg.equals("image")) { header.addCell("no image "); } else { header.addCell(createImageCell(orgImg)); } //second column ///description header.addCell(createTextCell(orgAbout)); header.addCell(createTextCell("")); PdfPTable RecieptTilte = new PdfPTable(3); // // tbl.setWidthPercentage(100); // RecieptTilte.setTotalWidth(575); RecieptTilte.setLockedWidth(true); // RecieptTilte.setHorizontalAlignment(Align.CENTER); RecieptTilte.setWidths(new int[] { 1, 1, 1 }); RecieptTilte.setSpacingBefore(8); RecieptTilte.setSpacingAfter(6); // RecieptTilte.getDefaultCell().setBorderWidthBottom(2); RecieptTilte.getDefaultCell().setBorderWidthLeft(0); RecieptTilte.getDefaultCell().setBorderWidthRight(0); RecieptTilte.addCell(""); RecieptTilte.addCell(store + " Transactions"); RecieptTilte.setSpacingAfter(8); RecieptTilte.addCell(""); PdfPTable RecieptitemsTitles = new PdfPTable(8); RecieptitemsTitles.setTotalWidth(575); RecieptitemsTitles.setWidths(new int[] { 1, 1, 2, 1, 1, 1, 1, 2 }); RecieptitemsTitles.setLockedWidth(true); RecieptitemsTitles.addCell(creatTextCellTitles("Item-Name")); RecieptitemsTitles.addCell(creatTextCellTitles("Quantiy")); RecieptitemsTitles.addCell(creatTextCellTitles("Type")); RecieptitemsTitles.addCell(creatTextCellTitles("Cash")); RecieptitemsTitles.addCell(creatTextCellTitles("From")); RecieptitemsTitles.addCell(creatTextCellTitles("To")); RecieptitemsTitles.addCell(creatTextCellTitles("R.No")); RecieptitemsTitles.addCell(creatTextCellTitles("Date")); // RecieptitemsTitles.addCell(creatTextCellTitles("Id")); // PdfPTable Recieptitems=new PdfPTable(4); for (int a = 0; a < items.size(); a++) { RecieptitemsTitles .addCell(createTextCellcolor(((TransactionsPojo) items.get(a)).getItem_name(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_quantity(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_type(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_cash(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_from(), a)); RecieptitemsTitles .addCell(createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_to(), a)); RecieptitemsTitles.addCell(createTextCellcolor( ((TransactionsPojo) items.get(a)).getTransaction_receipt_no_out(), a)); RecieptitemsTitles.addCell( createTextCellcolor(((TransactionsPojo) items.get(a)).getTransaction_time_string(), a)); // RecieptitemsTitles.addCell(createTextCellcolor(String.valueOf(((CartPojo)items.get(a)).getItem_id()),a)); } pdfp.add(header1); pdfp.add(header); pdfp.add(RecieptTilte); pdfp.add(RecieptitemsTitles); pdfp.close(); } catch (DocumentException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Printing.class.getName()).log(Level.SEVERE, null, ex); } // jComboBoxGroup if (Desktop.isDesktopSupported()) { try { File file = new File(chooser.getSelectedFile(), store + "tr" + DATE + ".pdf"); Desktop.getDesktop().open(file); } catch (Exception ex) { ex.printStackTrace(); } } } }
From source file:util.PDFconverter.java
public static void createPDF(String[] header, String[][] data, String path, String tittle, float[] columnWidths) { try {/*from w w w .j a va2 s. c om*/ Document doc = new Document(); PdfWriter.getInstance(doc, new FileOutputStream(path)); doc.open(); doc.setPageSize(PageSize.A4); doc.setMargins(10, 10, 10, 10); Font litle = new Font(Font.COURIER, 7, Font.NORMAL); Font norm = new Font(Font.TIMES_ROMAN, 8, Font.NORMAL); Font normBold = new Font(Font.TIMES_ROMAN, 8, Font.BOLD); Font TitleFont = new Font(Font.TIMES_ROMAN, 12, Font.BOLD); doc.add(Chunk.NEWLINE); Paragraph judul = new Paragraph(tittle, TitleFont); judul.setAlignment(Element.ALIGN_CENTER); doc.add(judul); // Paragraph tgl = new Paragraph("tanggal " + tanggal + "\n", TitleFont); // tgl.setAlignment(Element.ALIGN_CENTER); // doc.add(tgl); doc.add(Chunk.NEWLINE); PdfPTable table = new PdfPTable(header.length); table.setWidthPercentage(100f); for (String head : header) { table.addCell(new PdfPCell(new Phrase(head, normBold))); } for (String[] obj : data) { for (int i = 0; i < header.length; i++) { table.addCell(new PdfPCell(new Phrase(obj[i], norm))); } } //float[] columnWidths = new float[] {10f, 20f, 30f, 10f}; table.setWidths(columnWidths); doc.add(table); // Paragraph stamp = new Paragraph(new Chunk("this report has generated with QCMS by " + System.getProperty("user.name") + " on " + new Date(), litle)); // stamp.setAlignment(Element.ALIGN_BOTTOM); // stamp.setAlignment(Element.ALIGN_CENTER); // doc.add(stamp); // // Paragraph tanda = new Paragraph(new Chunk("Mengetahui,", norm)); // tanda.setSpacingBefore(100); // tanda.setAlignment(Element.ALIGN_RIGHT); // tanda.setAlignment(Element.ALIGN_BOTTOM); // doc.add(tanda); // // Paragraph nama = new Paragraph(new Chunk("MANAGER Dept.RnQ", norm)); // nama.setSpacingBefore(30); // nama.setAlignment(Element.ALIGN_RIGHT); // nama.setAlignment(Element.ALIGN_BOTTOM); // doc.add(nama); doc.close(); } catch (DocumentException | FileNotFoundException ex) { Logger.getLogger(PDFconverter.class.getName()).log(Level.SEVERE, null, ex); } }