List of usage examples for com.itextpdf.text.pdf PdfPTable setHeaderRows
public void setHeaderRows(int headerRows)
From source file:gov.utah.dts.det.ccl.documents.reporting.reports.TopFindingsReport.java
@Override public void render(Map<String, Object> context, OutputStream outputStream, FileDescriptor fileDescriptor) throws TemplateException { List<Object[]> results = getResults(context); setFileName(context, fileDescriptor); Document document = new Document(PAGE_SIZE, 36, 36, 36, 36); try {/*from w ww . j a v a 2 s . co m*/ PdfWriter.getInstance(document, outputStream); document.open(); StringBuilder sb = new StringBuilder((String) context.get(LICENSE_TYPE_KEY)); sb.append(" Top Findings Report"); Paragraph heading = new Paragraph(sb.toString(), HEADING_FONT); heading.setAlignment(Element.ALIGN_CENTER); document.add(heading); Date startDate = (Date) context.get(DATE_RANGE_START_KEY); Date endDate = (Date) context.get(DATE_RANGE_END_KEY); ReportType reportType = ReportType.valueOf((String) context.get(REPORT_TYPE_KEY)); clearStringBuilder(sb); sb.append(DATE_FORMATTER.format(startDate)); sb.append(" - "); sb.append(DATE_FORMATTER.format(endDate)); Paragraph date = new Paragraph(sb.toString(), FONT); date.setAlignment(Element.ALIGN_RIGHT); document.add(date); PdfPTable table = new PdfPTable(2); table.setHeaderRows(1); table.setSpacingBefore(FONT_SIZE); table.setWidthPercentage(100f); table.setWidths(new float[] { 80f, 20f }); setDefaultCellAttributes(table.getDefaultCell()); table.addCell(getHeaderCell("Rule Number")); table.addCell(getHeaderCell(reportType.getLabel())); double total = 0; for (Iterator<Object[]> itr = results.iterator(); itr.hasNext();) { Object[] row = itr.next(); Paragraph p = new Paragraph(); p.add(new Paragraph((String) row[0], TABLE_HEADER_FONT)); p.add(new Paragraph((String) row[1], FONT)); table.addCell(p); double rowTotal = ((BigDecimal) row[2]).doubleValue(); total += rowTotal; if (reportType == ReportType.CMP_AMOUNT) { PdfPCell cell = getCurrencyCell(CURRENCY_FORMATTER.format(rowTotal)); table.addCell(cell); } else { table.addCell(getNumberCell(Integer.toString((int) rowTotal))); } } PdfPCell totCell = getHeaderCell("Total"); totCell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(totCell); if (reportType == ReportType.CMP_AMOUNT) { PdfPCell cell = getHeaderCell(CURRENCY_FORMATTER.format(total)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell); } else { PdfPCell cell = getHeaderCell(Integer.toString((int) total)); table.addCell(cell); } document.add(table); } catch (DocumentException de) { throw new TemplateException(de); } document.close(); }
From source file:has.GenerateReceipt.java
private static void createTable(Section subCatPart, Vector Catering) throws BadElementException { PdfPTable table = new PdfPTable(3); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); // addEmptyLine(preface, 2); PdfPCell c1 = new PdfPCell(new Phrase("slno")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1);/* w ww .java 2s .c om*/ c1 = new PdfPCell(new Phrase("Date")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Item")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("price")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); CateringObject obj = (CateringObject) Catering.elementAt(0); float Totalbill = (float) obj.bill; // tb.addRow(new Object[]{new String(rs.getString("Name")),new String(rs.getString("I")),new String(obj.date),new String(obj.item),new Double(obj.bill) }); for (int f = 1; f < Catering.size(); f++) { obj = (CateringObject) Catering.elementAt(f); table.addCell("" + obj.date); table.addCell("" + obj.item); table.addCell("" + obj.bill); // tb.addRow (new Object[]{new String(""),new String(""),new String(obj.date),new String(obj.item),new Double(obj.bill) }); Totalbill = (float) (Totalbill + obj.bill); } /*table.addCell("1.0"); table.addCell("1.1"); table.addCell("1.2"); table.addCell("2.1"); table.addCell("2.2"); table.addCell("2.3");*/ subCatPart.add(table); }
From source file:ictproject.ReportGenerator.java
private PdfPTable getPaniKoSroth(String name) throws Exception { PdfPTable table = new PdfPTable(5); // 3 columns. table.getDefaultCell().setBackgroundColor(BaseColor.GRAY); table.setWidths(new int[] { 1, 1, 2, 1, 1 }); table.addCell(getNepaliPhrase("l;=g+="));//"..")); table.addCell(getNepaliPhrase("j8f g+="));//" .")); table.addCell(/*from w w w . ja v a 2 s. com*/ getNepaliPhrase("kfgL >f]t ;'Sb} uPsf] cj:yf-clt w]/}%,w]/}$,l7s}#,sd@,5}g!_"));// ? ?? ? ?( ,,,,)")); table.addCell(getNepaliPhrase("kf]v/Lsf] ;+Vof"));// ?")); table.addCell(getNepaliPhrase("s}lkmot"));//")); table.setHeaderRows(2); table.getDefaultCell().setBackgroundColor(null); try { Statement stmt = conn.createStatement(); String sql; String selected = name; sql = "SELECT * from bidamanpanikosrot where name='" + name + "'"; ResultSet rs = stmt.executeQuery(sql); //STEP 5: Extract data from result set while (rs.next()) { table.addCell(numberConverterToUnicode(rs.getString("serialNo"))); table.addCell(numberConverterToUnicode(rs.getString("wardNo"))); table.addCell(numberConverterToUnicode(rs.getString("paniKoSrotCount"))); table.addCell(numberConverterToUnicode(rs.getString("pokharicount"))); table.addCell(getNepaliPhrase(converter(rs.getString("remarks")))); } table.addCell(getNepaliPhrase("hDdf")); table.addCell(""); table.addCell(""); table.addCell(getSum(name, "pokharicount", "bidamanpanikosrot")); table.addCell(""); } catch (SQLException se) { //Handle errors for JDBC se.printStackTrace(); } return table; }
From source file:ictproject.ReportGenerator.java
private PdfPTable rogKoBibaran(String name) { PdfPTable table = new PdfPTable(6); // 3 columns. table.getDefaultCell().setBackgroundColor(BaseColor.GRAY); table.addCell(getNepaliPhrase("l;=g+="));//.."); table.addCell(getNepaliPhrase("l;=g+="));//;" "); table.addCell(getNepaliPhrase("aif{-@)^(&)_"));//"?""));///)"); table.addCell(getNepaliPhrase("aif{-@)&)&!_")); table.addCell(getNepaliPhrase("aif{-@)&)&!_")); table.addCell(getNepaliPhrase("s}lkmot")); table.setHeaderRows(1); table.getDefaultCell().setBackgroundColor(null); try {/*from w w w .ja v a2 s.c om*/ Statement stmt = conn.createStatement(); String sql; sql = "SELECT * from panijanyarogkabibaran where name='" + name + "'"; ResultSet rs = stmt.executeQuery(sql); //STEP 5: Extract data from result set while (rs.next()) { table.addCell(numberConverterToUnicode(rs.getString("SNo"))); table.addCell(getNepaliPhrase(converter(rs.getString("diseaseName")))); table.addCell(numberConverterToUnicode(rs.getString("year6970"))); table.addCell(numberConverterToUnicode(rs.getString("year7071"))); table.addCell(numberConverterToUnicode(rs.getString("year7172"))); table.addCell(getNepaliPhrase(converter(rs.getString("remarks")))); } } catch (SQLException se) { //Handle errors for JDBC se.printStackTrace(); } return table; }
From source file:ictproject.ReportGenerator.java
private PdfPTable actualBudget(String name, String tableName) { PdfPTable table = new PdfPTable(5); table.getDefaultCell().setBackgroundColor(BaseColor.GRAY); table.addCell(getNepaliPhrase("cfly{s jif{"));//artik barsa table.addCell(getNepaliPhrase("vfg]kfgL-?k}of_"));//khanepani table.addCell(getNepaliPhrase(";/;kmfO-?k}of_"));//sarsafai table.addCell(getNepaliPhrase("hDdf"));//jamma table.addCell(getNepaliPhrase("s}lkmot"));//kaifiyat table.setHeaderRows(1); table.getDefaultCell().setBackgroundColor(null); try {/* ww w . j a v a 2s. c om*/ Statement stmt = conn.createStatement(); String sql; sql = "SELECT * from " + tableName + " where name='" + name + "'"; ResultSet rs = stmt.executeQuery(sql); //STEP 5: Extract data from result set while (rs.next()) { table.addCell(getNepaliPhrase(rs.getString("arthikBarsa"))); table.addCell(numberConverterToUnicode(rs.getString("khanePani"))); table.addCell(numberConverterToUnicode(rs.getString("sarSafai"))); table.addCell(numberConverterToUnicode(rs.getString("total"))); table.addCell(getNepaliPhrase(converter(rs.getString("remarks")))); } table.addCell(getNepaliPhrase("hDdf"));//jamma table.addCell(getSum(name, "khanePani", tableName)); table.addCell(getSum(name, "sarSafai", tableName)); table.addCell(getSum(name, "total", tableName)); table.addCell(""); } catch (SQLException se) { //Handle errors for JDBC se.printStackTrace(); } return table; }
From source file:info.toegepaste.controller.PdfController.java
public void CreatePdf(long studentId) { //Fonts/*ww w . ja v a 2 s. c om*/ Font header = new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD); Font normal = new Font(Font.FontFamily.HELVETICA, 12, Font.NORMAL); //Declaration Student student = new Student(); List<Course> courses; List<Exam> exams = null; Score score; int totaal = 0; //totaal van een vak berekenen int maxScore = 0; //max soore van een test int aantalVakken = 0; //aantal vakken waaraan student heeft deelgenomen int klasgemiddelde = 0; //hulpvariabele om klasgemiddelde op te vragen Double totaalGemiddelde = 0.0; //eindpercentage Double vermenigvuldigfactor = 0.0; //om score op 20 weer te geven ArrayList<Integer> gemiddeldes = new ArrayList<Integer>(); //gemiddeldes per vak ArrayList<Integer> gemiddeldesKlas = new ArrayList<Integer>(); //gemiddelde klas per vak PdfPCell cell; //Document Document document = new Document(); //student opvullen student = pdfService.getStudent(studentId); //Tempfix //student.getClassgroup(); //cursussen opvullen courses = courseService.getWithClassgroup(student.getClassgroup()); for (int i = 0; i < courses.size(); i++) { //testen opvullen exams = pdfService.getExamsByCourse(courses.get(i)); for (int j = 0; j < exams.size(); j++) { score = pdfService.getScoreByExamAndStudent(exams.get(j), student); //nagaan of de student heeft deelgenomen aan de test if (score != null) { // score op 20 weergeven vermenigvuldigfactor = 20 / (double) exams.get(j).getTotal(); totaal += (int) (score.getScore() * vermenigvuldigfactor); } //klasgemiddelde voor een vak klasgemiddelde = pdfService.getAverageScoreByExam(exams.get(j)); gemiddeldesKlas.add(klasgemiddelde); } if (exams.size() > 0) { gemiddeldes.add(totaal / exams.size()); totaalGemiddelde += totaal / exams.size(); aantalVakken++; } totaal = 0; exams.clear(); } totaalGemiddelde = totaalGemiddelde / aantalVakken * 5; ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try { PdfWriter.getInstance(document, outputStream); document.open(); //header document.add(new Paragraph("Studenten Rapport", header)); document.add(new Paragraph("Student:" + student.getFirstname() + " " + student.getLastname(), normal)); document.add(new Paragraph("Klas:" + student.getClassgroup(), normal)); document.add(new Paragraph("Alle scores worden op 20 weergegeven", normal)); //table PdfPTable table = new PdfPTable(3); //create tableheaders PdfPCell c1 = new PdfPCell(new Phrase("Vak")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Score")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Gemiddelde")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); for (int i = 0; i < aantalVakken; i++) { cell = new PdfPCell(new Phrase(gemiddeldes.get(i).toString())); if (gemiddeldes.get(i) < 10) { cell.setBackgroundColor(BaseColor.RED); } table.addCell(courses.get(i).getName()); table.addCell(cell); table.addCell(gemiddeldesKlas.get(i).toString()); } document.add(table); //end document.add(new Paragraph("Totaal behaald percentage:" + totaalGemiddelde, normal)); document.close(); } catch (DocumentException e) { e.printStackTrace(); // } catch (FileNotFoundException e) { // e.printStackTrace(); } MultiPartEmail email = new MultiPartEmail(); email.setHostName("smtp.googlemail.com"); email.setSmtpPort(587); email.setSSLOnConnect(true); email.setAuthenticator(new DefaultAuthenticator("bitmescoretracker@gmail.com", "bitmeScore")); try { email.addTo(student.getEmail()); email.setFrom("bitmescoretracker@gmail.com"); email.setSubject("Requested scores , scoretracker"); email.setMsg("Here are the scores you requested!"); // EmailAttachment attachment = new EmailAttachment(); //attachment.setDescription("PDF met uw punten"); // attachment.setName(student.getFirstname() + " " + student.getLastname() + " scores"); byte[] bytes = outputStream.toByteArray(); DataSource source = new javax.mail.util.ByteArrayDataSource(bytes, "application/pdf"); System.out.println("Stuff"); /* try{ source = outputStream.write(bytes); }catch(IOException e){ e.printStackTrace(); }*/ email.attach(source, student.getFirstname() + " " + student.getLastname() + " scores", "stuff"); email.send(); } catch (EmailException ex) { ex.printStackTrace(); } }
From source file:info.toegepaste.www.service.ProjectServiceImpl.java
public void createPDFje(List<Score> scores) { try {/*from ww w. j av a 2 s. c o m*/ Document document = new Document(); // Tijdelijk bestand aanmaken (PDF) File temp = File.createTempFile("resultaat", ".pdf"); //PDF openen en bewerken PdfWriter.getInstance(document, new FileOutputStream(temp.getAbsolutePath())); document.open(); // MetaData toevoegen document.addTitle("Resulaten"); document.addAuthor("Score Tracker"); document.addCreator("Score Tracker"); // Titel toevoegen Paragraph preface = new Paragraph(); preface.add(new Paragraph("Resultaten van de gekozen scores")); addEmptyLine(preface, 2); document.add(preface); // Tabel toevoegen met 5 kolommen PdfPTable table = new PdfPTable(5); PdfPCell c1 = new PdfPCell(new Phrase("Klas")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Student")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Vak")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Test")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Resultaat")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); table.setHeaderRows(1); //tabel opvullen met scores uit "List<Score> scores" for (Score score : scores) { table.addCell(score.getStudent().getKlas().getGroep()); table.addCell(score.getStudent().getNaam()); table.addCell(score.getTest().getVak().getNaam()); table.addCell(score.getTest().getNaam()); table.addCell(score.getPunt() + " / " + score.getTest().getMaxScore()); } // breedte van de kolommen float[] columnWidths = new float[] { 10f, 25f, 20f, 20f, 15f }; table.setWidths(columnWidths); document.add(table); document.close(); // PDF downloaden exportPdf(temp); } catch (Exception e) { e.printStackTrace(); } }
From source file:info.toegepaste.www.service.ProjectServiceImpl.java
public void createPDF(List<Score> scores) { try {/*w ww . j av a 2 s. c o m*/ Document document = new Document(); // Tijdelijk bestand aanmaken (PDF) File temp = File.createTempFile("resultaat", ".pdf"); //PDF openen en bewerken PdfWriter.getInstance(document, new FileOutputStream(temp.getAbsolutePath())); document.open(); // MetaData toevoegen document.addTitle("Resulaten"); document.addAuthor("Score Tracker"); document.addCreator("Score Tracker"); // Titel toevoegen Paragraph preface = new Paragraph(); preface.add(new Paragraph("Resultaten van de gekozen scores")); addEmptyLine(preface, 2); document.add(preface); // Tabel toevoegen PdfPTable table = new PdfPTable(4); PdfPCell c1 = new PdfPCell(new Phrase("Student")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Vak")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Test")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); c1 = new PdfPCell(new Phrase("Resultaat")); c1.setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(c1); table.setHeaderRows(1); //tabel opvullen met scores uit "List<Score> scores" for (Score score : scores) { table.addCell(score.getStudent().getNaam()); table.addCell(score.getTest().getVak().getNaam()); table.addCell(score.getTest().getNaam()); table.addCell(score.getPunt() + " / " + score.getTest().getMaxScore()); } // breedte van de kolommen float[] columnWidths = new float[] { 10f, 25f, 20f, 20f, 15f }; table.setWidths(columnWidths); document.add(table); document.close(); // PDF downloaden exportPdf(temp); } catch (Exception e) { e.printStackTrace(); } }
From source file:lk.score.androphsy.report.ReportPdf.java
License:Open Source License
private void CreateTable(Paragraph subpara, String feature) { System.out.println("Report Create Table: " + feature); try {/*from w ww . j a v a 2 s. c o m*/ String query = ""; Connection conn = new ConnectDb().getConnection(); Statement stmt = conn.createStatement(); if (feature == "PRIMARY_ACC") { query = "SELECT host AS 'Account Type', username AS 'User Name'," + " password AS 'Password (HASHED)'" + " FROM Androspy_Account" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND primary_acc = " + 1; } else if (feature == "OTHER_ACC") { query = "SELECT host AS 'Account Type', username AS 'User Name'," + " password AS 'Password'" + " FROM Androspy_Account" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND primary_acc != " + 1; } else if (feature == "SMS") { query = "SELECT subject AS 'Subject', body AS 'Message Body'," + " type AS 'Message Type', date_received AS 'Received Date', date_sent AS 'Send Date'" + " FROM Sms" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature == "Phone Book") { query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " times_contacted AS 'Times Contacted', last_time_contacted AS 'Last Contacted Date'" + " FROM Contacts" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature == "Gmail") { query = "SELECT fromaddress AS 'From Address'," + " toaddress AS 'To Address', ccaddress AS 'CC Address', bccaddress AS 'BCC Address'," + " replytoaddress AS 'Reply To Address', subject AS 'Subject', snippet As 'Message Body', " + "datesent AS 'Send Date', datereceive AS 'Received Date'" + " FROM Gmail_Store" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature == "Calendar") { query = "SELECT title AS 'Title', description AS 'Event', location AS 'Location'," + " start_time AS 'Start Time', end_time AS 'End Time', created_by AS 'Creator'" + " FROM Calendar_Event" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature == "YouTube") { query = "SELECT query AS 'Search' , search_date AS 'Time Stamp'" + " FROM Youtube_History" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature.equals("FACEBOOK_MESSAGES")) { query = "SELECT IFNULL(sender, '') AS 'Sender'," + " IFNULL(text, '') AS 'Message'," + " IFNULL(conversation_date, '') AS 'Date'," + " IFNULL(logitude, '') AS 'Longitude'," + " IFNULL(latitude, '') AS 'Latitude'" + " FROM Facebook_Message" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature.equals("FACEBOOK_CONTACTS")) { query = "SELECT IFNULL(first_name, '') AS 'First Name'," + " IFNULL(last_name, '') AS 'Last Name'," + " IFNULL(display_name, '') AS 'Display Name'," + " IFNULL(added_time, '') AS 'Time Stamp'," + " IFNULL(type, '') AS 'Contact Type'" + " FROM Fb_Contacts" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature.equals("FACEBOOK_NOTIFICATIONS")) { query = "SELECT IFNULL(notification, '') AS 'Notification'," + " IFNULL(update_date, '') AS 'Date'" + " FROM Facebook_Notifications" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature.equals("LINKEDIN_PROFILE")) { query = "SELECT first_name AS 'First Name', last_name AS 'Last Name', display_name AS 'Display Name'," + "country AS 'Country', join_date AS 'Join Date', connections AS 'No of Connections'" + " FROM Linkedin_Profile" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature.equals("LINKEDIN_CONNECTIONS")) { query = "SELECT IFNULL(first_name, '') AS 'First Name'," + " IFNULL(last_name, '') AS 'Last Name'," + " IFNULL(display_name, '') AS 'Display Name'," + " IFNULL(title, '') AS 'Title'" + " FROM Linkedin_Connections" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature.equals("LINKEDIN_INVITATIONS")) { query = "SELECT IFNULL(from_display_name, '') AS 'Sender Name'," + " IFNULL(title, '') AS 'Title'," + " IFNULL(invitation_date, '') AS 'Invitation Date'" + " FROM Linkedin_Invitation" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature.equals("LINKEDIN_MESSAGES")) { query = "SELECT from_display_name AS 'Remote Party', from_title AS 'Remote Party Title'," + " message_date AS 'Message Date', subject AS Subject, message_body AS Message" + " FROM Linkedin_Message" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature.equals("DEFAULT_BROWSER_HISTORY")) { query = "SELECT title AS Title, url AS URL, " + "last_visit_date AS 'Last Visit Date', visits AS 'No of Visitis'" + " FROM Browser_History" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'DEFAULTB'"; } else if (feature.equals("DEFAULT_BOOKMARKS")) { query = "SELECT title AS Title, url AS URL, " + "created_date AS 'Creaded Date', modified_date AS 'Modified Date', deleted AS Deleted," + "account_name AS 'Created By', account_type AS 'Account Type'" + " FROM Androspy_Bookmark" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'DEFAULTB'"; } else if (feature.equals("DEFAULT_WEB_FORM_DATA")) { query = "SELECT url AS 'URL', name AS 'Parameter Name', value AS 'Parameter Value'" + " FROM WebForm f, WebFormData d" + " WHERE f.case_id = d.case_id AND f.device_id = d.device_id" + " AND d.urlid = f.id" + " AND d.case_id = " + AndrospyMain.gb_CaseId + " AND d.device_id = " + AndrospyMain.gb_DeviceId; } else if (feature.equals("DEFAULT_COOKIES")) { query = "SELECT host AS 'Host', " + "cookie_name AS 'Cookie Name', cookie_value AS 'Cookie Value', path AS Path, " + "secure AS Secure, httponly AS 'Http Only', created_date AS 'Created Date', " + "expire_date AS 'Expire Date', last_access_date AS 'Last Access Date'" + " FROM Browser_Cookies" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'DEFAULTB'"; } else if (feature.equals("DEFAULT_WEB_SEARCH")) { query = "SELECT search_text AS 'Search Text', " + "search_date AS 'Search Date'" + " FROM WebSearch" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'DEFAULTB'"; } else if (feature.equals("CHROME_BROWSER_HISTORY")) { query = "SELECT title AS Title, url AS URL, " + "last_visit_date AS 'Last Visit Date', visits AS 'No of Visitis'" + " FROM Browser_History" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'CHROME'"; } else if (feature.equals("CHROME_COOKIES")) { query = "SELECT host AS 'Host', " + "cookie_name AS 'Cookie Name', cookie_value AS 'Cookie Value', path AS Path, " + "secure AS Secure, httponly AS 'Http Only', created_date AS 'Created Date', " + "expire_date AS 'Expire Date', last_access_date AS 'Last Access Date'" + " FROM Browser_Cookies" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'CHROME'"; } else if (feature.equals("CHROME_WEB_SEARCH")) { query = "SELECT search_text AS 'Search Text', " + "search_date AS 'Search Date'" + " FROM WebSearch" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'CHROME'"; } else if (feature.equals("CHROME_CREDIT_CARD")) { query = "SELECT name AS Name, expire_month AS 'Expire Month', expire_year AS 'Exire Year', " + "modified_date AS 'Modified Date'" + " FROM Browser_Credit_Card" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'CHROME'"; } else if (feature.equals("Firefox_BROWSER_HISTORY")) { query = "SELECT title AS Title, url AS URL, " + "last_visit_date AS 'Last Visit Date', visits AS 'No of Visitis'" + " FROM Browser_History" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'Firefox'"; } else if (feature.equals("Firefox_BOOKMARKS")) { query = "SELECT title AS Title, url AS URL, " + "created_date AS 'Creaded Date', modified_date AS 'Modified Date', deleted AS Deleted," + "account_name AS 'Created By', account_type AS 'Account Type'" + " FROM Androspy_Bookmark" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'Firefox'"; } else if (feature.equals("Firefox_WEB_SEARCH")) { query = "SELECT search_text AS 'Search Text', " + "search_date AS 'Search Date'" + " FROM WebSearch" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'Firefox'"; } else if (feature.equals("Firefox_COOKIES")) { query = "SELECT host AS 'Host', " + "cookie_name AS 'Cookie Name', cookie_value AS 'Cookie Value', path AS Path, " + "secure AS Secure, httponly AS 'Http Only', created_date AS 'Created Date', " + "expire_date AS 'Expire Date', last_access_date AS 'Last Access Date'" + " FROM Browser_Cookies" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND browser = 'Firefox'"; } else if (feature == "ALL_CALL_LOG") { query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', duration AS 'Call Duration', " + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND logtype = " + 100; } else if (feature == "INCOMING_CALLS") { query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', duration AS 'Call Duration', " + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND logtype = " + 100 + " AND type = " + 1; } else if (feature == "MISSED_CALLS") { query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', duration AS 'Call Duration', " + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND logtype = " + 100 + " AND type = " + 3; } else if (feature == "CANCELLED_CALLS") { query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', duration AS 'Call Duration', " + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND logtype = " + 500; } else if (feature == "OUTGOING_CALLS") { query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', duration AS 'Call Duration', " + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND logtype = " + 100 + " AND type = " + 2; } else if (feature == "ALL_SMS_LOG") { query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', " + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', " + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND logtype = " + 300; } else if (feature == "SMS_INBOX") { query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', " + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', " + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND logtype = " + 300 + " AND type = " + 1; } else if (feature == "SMS_OUTBOX") { query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', " + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', " + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND logtype = " + 300 + " AND type != " + 1; } else if (feature == "ALL_MMS_LOG") { query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', " + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', " + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND logtype = " + 200; } else if (feature == "MMS_INBOX") { query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', " + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', " + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND logtype = " + 200 + " AND type = " + 1; } else if (feature == "MMS_OUTBOX") { query = "SELECT contact_no AS 'Contact No', name AS 'Name'," + " date AS 'Contacted Date', " + "messageid AS 'Message_Id', m_subject AS 'Message Subject', m_content AS 'Message Body', " + "countryiso AS 'Country Code', geolocationcode AS 'Geo Location'" + " FROM Event_Log" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId + " AND logtype = " + 200 + " AND type != " + 1; } else if (feature == "Wi-Fi Access Points") { query = "SELECT ssid AS 'SSID', password AS 'Password', key_mgmt AS 'Key Management'" + " FROM Wifi_Info" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature.equals("Wi-Fi Access Points")) { query = "SELECT ssid AS 'SSID', password AS 'Password', key_mgmt AS 'Key Management'" + " FROM Wifi_Info" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature == "BT_USED") { query = "SELECT device_address AS 'Target Device BT Address', mimetype AS 'MIME Type', " + " in_file_name AS 'File Name', totalbytes AS 'File Size', location AS Location, direction AS Direction, visibility AS Visibility, confirm AS Confirm," + " status AS 'Transfer Status', date AS 'Transfer Date', scanned As Scanned" + " FROM Bluetooth_Tranfer" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature == "BT_SEEN") { query = "SELECT bmac AS 'Bluetooth Address'," + " device_name AS 'Device Name', seen_date AS 'Last Seen Date', 'used_date' AS 'Last_Paired_Date'" + " FROM Bluetooth_Device" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature == "Skype Account") { System.out.println("Skype Account"); query = "SELECT skypename, fullname, birthday, country, city reg_date, gender" + " FROM Skype_Account" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature == "Skype Contacts") { System.out.println("Skype Contacts"); query = "SELECT skypename, fullname, birthday, displayname, country, city, gender, phone" + " FROM Skype_Contacts" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature == "Skype Calls") { System.out.println("Skype Calls"); query = "SELECT identity, display_name, call_duration, start_time_stamp" + " FROM Skype_Call" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } else if (feature == "Skype Messages") { System.out.println("Skype Messages"); query = "SELECT author, from_display_name, dialog_partner, message, time_stamp" + " FROM Skype_Message" + " WHERE case_id = " + AndrospyMain.gb_CaseId + " AND device_id = " + AndrospyMain.gb_DeviceId; } if (query != ("")) { if (!bflagall) { query += " AND favourite = " + 1; } System.out.println("query: " + query); ResultSet rs = stmt.executeQuery(query); ResultSetMetaData rsmeta = rs.getMetaData(); int colcount = rsmeta.getColumnCount(); PdfPTable pdftable = new PdfPTable(colcount); pdftable.setWidthPercentage(100 / colcount); pdftable.setTotalWidth(527); pdftable.setLockedWidth(true); for (int i = 1; i <= colcount; i++) { PdfPCell c1 = new PdfPCell(new Phrase(rsmeta.getColumnLabel(i))); c1.setHorizontalAlignment(Element.ALIGN_CENTER); pdftable.addCell(c1); } pdftable.setHeaderRows(1); while (rs.next()) { for (int i = 1; i <= colcount; i++) { System.out.println("add table cell report " + rs.getString(i)); pdftable.addCell(rs.getString(i)); } } subpara.add(pdftable); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:net.pickapack.util.TableHelper.java
License:Open Source License
/** * Generate the table./*from w w w . ja va 2 s.co m*/ * * @param fileName the file name * @param columns the list of columns * @param rows the list of rows */ public static void generateTable(String fileName, List<String> columns, List<List<String>> rows) { Document document = new Document(A3_EXTRA_LANDSCAPE); try { PdfWriter.getInstance(document, new FileOutputStream(fileName)); document.open(); PdfPTable table = new PdfPTable(columns.size()); table.setWidthPercentage(100.0f); addRow(table, true, columns); for (List<String> row : rows) { addRow(table, false, row); } document.add(table); table.setHeaderRows(0); document.close(); } catch (Exception e) { e.printStackTrace(); } }