List of usage examples for com.itextpdf.text BaseColor DARK_GRAY
BaseColor DARK_GRAY
To view the source code for com.itextpdf.text BaseColor DARK_GRAY.
Click Source Link
From source file:Subordinate.request.java
private void jLabel15MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel15MouseClicked Document document = new Document(); try {//from w ww. j ava 2 s. c om PdfWriter.getInstance(document, new FileOutputStream("printreq.pdf")); document.open(); SimpleDateFormat td = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date now = new Date(); String tdnow = td.format(now); Paragraph paragraph = new Paragraph(ALLBITS); paragraph.add(new Paragraph(tdnow)); paragraph.add(new Paragraph("Request : \n\n", FontFactory.getFont(FontFactory.COURIER_BOLD, 20, Font.BOLD, BaseColor.DARK_GRAY))); document.add(paragraph); PdfPTable table = new PdfPTable(2); table.addCell("ID Request :"); table.addCell(request.intGetter("idRequest") + ""); table.addCell("Request type :"); table.addCell(request.stringGetter("requestType")); table.addCell("Client name :"); table.addCell(request.stringGetter("clientName")); table.addCell("Phone number :"); table.addCell(request.stringGetter("clientTel")); table.addCell("Address 1 :"); table.addCell(request.stringGetter("address1")); table.addCell("Address 2 :"); table.addCell(request.stringGetter("address2")); document.add(table); document.close(); /* Open Pdf */ Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { desktop.open(new File("printreq.pdf")); } else { System.out.println("Open is not supported"); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Subordoante.Sub.java
public void openPDF() { Document document = new Document(); try {//www .jav a 2 s . co m PdfWriter.getInstance(document, new FileOutputStream("printreq.pdf")); document.open(); SimpleDateFormat td = new SimpleDateFormat("yyyy-MM-dd"); Date now = new Date(); String tdnow = td.format(now); Paragraph paragraph = new Paragraph(ALLBITS); paragraph.add(new Paragraph(tdnow)); paragraph.add(new Paragraph("Request : \n\n", FontFactory.getFont(FontFactory.TIMES, 20, Font.BOLD, BaseColor.DARK_GRAY))); document.add(paragraph); PdfPTable table = new PdfPTable(2); table.addCell("ID Request :"); table.addCell(request.intGetter("idRequest") + ""); table.addCell("Request type :"); table.addCell(request.stringGetter("requestNet")); table.addCell("Client name :"); table.addCell(request.stringGetter("clientName")); table.addCell("Phone number :"); table.addCell(request.stringGetter("clientTel")); table.addCell("Address :"); table.addCell(request.stringGetter("address1")); if (request.stringGetter("requestType").equalsIgnoreCase("Transfer")) { table.addCell("Transfer address:"); table.addCell(request.stringGetter("address2")); } else if (request.stringGetter("requestType").equalsIgnoreCase("Maintenance")) { table.addCell("Problem :"); table.addCell(request.stringGetter("problem")); } else ; document.add(table); document.close(); /* Open Pdf */ Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { desktop.open(new File("printreq.pdf")); } else { System.out.println("Open is not supported"); } } catch (DocumentException | IOException ex) { } }
From source file:timeclock.reports.EmployeeListReport.java
@Override public PdfPTable createTable(List list) { PdfPTable table = new PdfPTable(new float[] { 2, 3, 4, 1, 1 }); table.setWidthPercentage(100f);//from ww w .j a v a 2 s. c o m PdfPCell dCell = table.getDefaultCell(); dCell.setUseAscender(true); dCell.setUseDescender(true); dCell.setPadding(3); dCell.setHorizontalAlignment(Element.ALIGN_CENTER); dCell.setBackgroundColor(BaseColor.DARK_GRAY); table.addCell(new Phrase("Employee ID", MyFonts.font.get("header"))); table.addCell(new Phrase("First Name", MyFonts.font.get("header"))); table.addCell(new Phrase("Last Name", MyFonts.font.get("header"))); table.addCell(new Phrase("Salary", MyFonts.font.get("header"))); table.addCell(new Phrase("Admin", MyFonts.font.get("header"))); dCell.setBackgroundColor(null); table.setHeaderRows(1); table.setFooterRows(0); // used for alternating row color int rowCount = 0; // Display all employees for (Object obj : list) { Employee emp = (Employee) obj; rowCount++; dCell.setBackgroundColor((rowCount % 2 == 0 ? BaseColor.LIGHT_GRAY : null)); table.addCell(new Paragraph(Integer.toString(emp.getEmployeeID()), MyFonts.font.get("normal"))); table.addCell(new Paragraph(emp.getFirstName(), MyFonts.font.get("normal"))); table.addCell(new Paragraph(emp.getLastName(), MyFonts.font.get("normal"))); table.addCell(new Paragraph(emp.getIsSalary_bool() ? "Yes" : "No", MyFonts.font.get("normal"))); table.addCell(new Paragraph(emp.getIsAdmin_bool() ? "Yes" : "No", MyFonts.font.get("normal"))); } return table; }
From source file:timeclock.reports.EmployeeTimeReport.java
@Override public PdfPTable createTable(List list) { // Create table and set basic table properties PdfPTable table = new PdfPTable(new float[] { 1, 4, 4, 3 }); table.setWidthPercentage(100f);/*from w ww.j a v a2 s . c om*/ PdfPCell dCell = table.getDefaultCell(); dCell.setUseAscender(true); dCell.setUseDescender(true); dCell.setPadding(3); dCell.setHorizontalAlignment(Element.ALIGN_CENTER); // Set header background color dCell.setBackgroundColor(BaseColor.DARK_GRAY); // Display the employee first in header table.addCell(new Phrase(Integer.toString(employee.getEmployeeID()), MyFonts.font.get("header"))); table.addCell(new Phrase(employee.getFirstName(), MyFonts.font.get("header"))); table.addCell(new Phrase(employee.getLastName(), MyFonts.font.get("header"))); table.addCell(new Phrase("", MyFonts.font.get("header"))); // Display the column names in header table.addCell(new Phrase("", MyFonts.font.get("header"))); table.addCell(new Phrase("Time In", MyFonts.font.get("header"))); table.addCell(new Phrase("Time Out", MyFonts.font.get("header"))); table.addCell(new Phrase("Time Worked", MyFonts.font.get("header"))); // Reset the cell background color dCell.setBackgroundColor(null); // Set the number of rows included in the header and footer table.setHeaderRows(2); table.setFooterRows(0); // Make a variable to hold the total of all time worked long totalTimeDiff = 0; // used for alternating row color int rowCount = 0; // Display all time punches for (Object obj : list) { TimePunch tp = (TimePunch) obj; rowCount++; dCell.setBackgroundColor((rowCount % 2 == 0 ? BaseColor.LIGHT_GRAY : null)); Timestamp ts1, ts2; ts1 = tp.getPunchInTimestamp(); ts2 = tp.getPunchOutTimestamp(); totalTimeDiff += ts2.getTime() - ts1.getTime(); String id = Integer.toString(tp.getPunchId()); String in = DateUtils.getDateTimeFromTimestamp(ts1); String out = DateUtils.getDateTimeFromTimestamp(ts2); String diff = DateUtils.getTimestampDiff_Str(ts1, ts2); // Add information to row table.addCell(new Paragraph("", MyFonts.font.get("normal"))); table.addCell(new Paragraph(in, MyFonts.font.get("normal"))); table.addCell(new Paragraph(out, MyFonts.font.get("normal"))); table.addCell(new Paragraph(diff, MyFonts.font.get("normal"))); } // Set background to null dCell.setBackgroundColor(null); // Get total time worked and create a totals row table.addCell(new Paragraph("", MyFonts.font.get("normal"))); table.addCell(new Paragraph("", MyFonts.font.get("normal"))); table.addCell(new Paragraph("Total:", MyFonts.font.get("bold"))); table.addCell(new Paragraph(DateUtils.getTimeStrFromLong(totalTimeDiff), MyFonts.font.get("bold"))); return table; }