List of usage examples for com.itextpdf.text FontFactory TIMES_BOLD
String TIMES_BOLD
To view the source code for com.itextpdf.text FontFactory TIMES_BOLD.
Click Source Link
From source file:se.wsu.lmw.Controls.Report.java
public void Create_report() { try {/* w ww .j a v a 2 s .c om*/ Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("Booklist_Report.pdf")); document.open(); document.add(new Paragraph( "----------------------------------------Library-------------------------------------", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLACK))); document.add(new Paragraph(new Date().toString())); document.add(new Paragraph( "----------------------------------------------------------------------------------------------------------------------------------")); document.add(new Paragraph("_________________________________________", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.WHITE))); PdfPTable table = new PdfPTable(new float[] { 35, 45, 35, 45, 45, 45, 45, 45 }); table.addCell("Book ID"); table.addCell("Book name"); table.addCell("Total Qty"); table.addCell("Available Qty"); table.addCell("Librarian ID"); table.addCell("Rack ID"); table.addCell("Category ID"); table.addCell("Publisher ID"); ResultSet result = new GetBookDetails().getBook(); while (result.next()) { table.addCell(result.getString(1)); table.addCell(result.getString(2)); table.addCell(result.getString(3)); table.addCell(result.getString(4)); table.addCell(result.getString(5)); table.addCell(result.getString(6)); table.addCell(result.getString(7)); table.addCell(result.getString(9)); } document.add(table); document.add(new Paragraph("_________________________________________", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.WHITE))); document.add(new Paragraph("_________________________________________", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.WHITE))); document.close(); Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "Booklist_Report.pdf"); } catch (Exception e) { System.out.println(e); JOptionPane.showMessageDialog(null, "report not created", "Error", 3); } }
From source file:se.wsu.lmw.Controls.Report.java
public void Create_report2() { try {//from w ww . j av a2 s. co m Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("Borrowed_Booklist.pdf")); document.open(); document.add(new Paragraph( "----------------------------------------Library-------------------------------------", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLACK))); document.add(new Paragraph(new Date().toString())); document.add(new Paragraph( "----------------------------------------------------------------------------------------------------------------------------------")); document.add(new Paragraph("_________________________________________", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.WHITE))); PdfPTable table = new PdfPTable(6); table.addCell("Member ID"); table.addCell("Book ID"); table.addCell("Librarian ID"); table.addCell("Borrowed date"); table.addCell("Returned date"); table.addCell("Borrowed ID"); ResultSet result = new GetBookDetails().getBorrowed(); while (result.next()) { table.addCell(result.getString(1)); table.addCell(result.getString(2)); table.addCell(result.getString(3)); table.addCell(result.getString(4)); table.addCell(result.getString(5)); table.addCell(result.getString(6)); } document.add(table); document.add(new Paragraph("_________________________________________", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.WHITE))); document.add(new Paragraph("_________________________________________", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.WHITE))); document.close(); Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "Borrowed_Booklist.pdf"); } catch (Exception e) { System.out.println(e); JOptionPane.showMessageDialog(null, "report not created", "Error", 3); } }
From source file:servlet.SalesReportPDF.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w.j av a 2 s. co m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { Document document = new Document(); List<ArrayList> data = productSession.getEventList(); List<ArrayList> sessions = getAllProductDetailsLocal.getAllSessions(); DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); //get current date time with Date() Date date = new Date(); //System.out.println(dateFormat.format(date)); @SuppressWarnings("unused") PdfWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream("C:/Users/Yong Jing Ying/Desktop/EventRecords.pdf")); document.open(); document.add(new Paragraph("Management Report", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLUE))); document.add(new Paragraph("PDF created on " + dateFormat.format(date).toString() + "\n", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); document.add(new Paragraph( "------------------------------------------------------------------------------------", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLACK))); for (int i = 0; i < data.size(); i++) { document.add(new Paragraph(data.get(i).get(1).toString() + " Event Details ", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); document.add(new Paragraph("Event Type : " + data.get(i).get(4).toString() + "\nStart Date : " + data.get(i).get(2).toString() + "\nEnd Date : " + data.get(i).get(3).toString() + "\nProperty Name : " + data.get(i).get(5).toString() + "\nNo of Category : " + data.get(i).get(6).toString() + "\nPromotions : " + data.get(i).get(7).toString() + "\n\n")); document.add(new Paragraph("Session", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); PdfPTable table = new PdfPTable(6); //table.addCell("item1"); table.setSpacingBefore(5); table.setSpacingAfter(5); table.setWidths(new int[] { 1, 2, 3, 3, 3, 3 }); table.setWidthPercentage(100); PdfPCell cell; cell = new PdfPCell(new Phrase("No:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("Name:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("Description:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("Start:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("End:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); cell = new PdfPCell(new Phrase("TicketPrices:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.CYAN); table.addCell(cell); for (int j = 0; j < sessions.size(); j++) { if (sessions.get(j).get(1).toString().equals(data.get(i).get(4).toString()) && sessions.get(j).get(0).toString().equals(data.get(i).get(0).toString())) { cell = new PdfPCell(new Phrase(sessions.get(j).get(8).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(4).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(5).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(6).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(7).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(9).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); } } document.add(table); document.add(new Paragraph("\n")); document.add(new Paragraph("Alert", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); table = new PdfPTable(6); //table.addCell("item1"); table.setSpacingBefore(5); table.setSpacingAfter(5); table.setWidths(new int[] { 1, 2, 2, 3, 3, 3 }); table.setWidthPercentage(100); cell = new PdfPCell(new Phrase("No:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); cell = new PdfPCell(new Phrase("Alert Type:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); cell = new PdfPCell(new Phrase("Below Sales:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); cell = new PdfPCell(new Phrase("In-Charged Email:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); cell = new PdfPCell(new Phrase("Start:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); cell = new PdfPCell(new Phrase("End:", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(BaseColor.GREEN); table.addCell(cell); for (int j = 0; j < sessions.size(); j++) { if (sessions.get(j).get(1).toString().equals(data.get(i).get(4).toString()) && sessions.get(j).get(0).toString().equals(data.get(i).get(0).toString()) && sessions.get(j).size() == 15) { cell = new PdfPCell(new Phrase(sessions.get(j).get(8).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(10).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(11).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(12).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(13).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); cell = new PdfPCell(new Phrase(sessions.get(j).get(14).toString())); cell.setBackgroundColor(BaseColor.WHITE); table.addCell(cell); } } document.add(table); document.add(new Paragraph("\n\n")); } document.close(); Thread.sleep(1000); PrintWriter out = response.getWriter(); String fileName = "EventRecords.pdf"; String filePath = "C:/Users/Yong Jing Ying/Desktop/"; response.setContentType("APPLICATION/OCTET-STREAM"); response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\""); FileInputStream fi = new FileInputStream("C:/Users/Yong Jing Ying/Desktop/EventRecords.pdf"); int i; while ((i = fi.read()) != -1) { out.write(i); } out.close(); fi.close(); } catch (Exception ex) { Logger.getLogger(SalesReportPDF.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:SessionBean.ReportMgt.ReportMgtBean.java
License:Open Source License
public void createMonthlyReport(Integer startYear, Integer startMonth, Integer endYear, Integer endMonth) { try {/* ww w .java 2s .c om*/ String RESULT; System.out.print("start"); if (startYear.equals(endYear) && startMonth.equals(endMonth)) { RESULT = "d:/GeneralReport-" + startYear + "." + startMonth + ".pdf"; } else { RESULT = "d:/GeneralReport-" + startYear + "." + startMonth + "-" + endYear + "." + endMonth + ".pdf"; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); Document document = new Document(); PdfWriter.getInstance(document, baos); document.open(); Image image = Image.getInstance("d:/logo-4227.png"); image.scaleAbsolute(150, 50); document.add(new Paragraph("")); document.add(image); Calendar targetPeriod = Calendar.getInstance(); int month = targetPeriod.get(Calendar.MONTH) + 1; int year = targetPeriod.get(Calendar.YEAR); String reportTile; document.add(new Paragraph("WineXpress General Sales Report", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLACK))); if (startYear.equals(endYear) && startMonth.equals(endMonth)) { reportTile = startYear + "." + startMonth; document.add(new Paragraph(reportTile, FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.RED))); } else { reportTile = startYear + "." + startMonth + "-" + endYear + "." + endMonth; document.add(new Paragraph(reportTile, FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.RED))); } document.add(new Paragraph("Generated Time: " + new Date().toString(), FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.PLAIN, BaseColor.BLACK))); document.add(new Paragraph(" ")); document.add(new Paragraph( "--------------------------------------------------------------------------------------------------------------------------")); PdfPTable table = new PdfPTable(6); table.getDefaultCell().setBorder(0); // PdfPCell cell= new PdfPCell(new Paragraph("Wine Name")); // cell.setColspan(4); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setBackgroundColor(BaseColor.BLACK); // table.addCell(cell); table.addCell("Item ID"); table.addCell("Item Name"); table.addCell("Sales (bottle)"); table.addCell("Revenue (SGD)"); table.addCell("Cost (SGD)"); table.addCell("Profit (SGD)"); Integer totalSales = 0; Double totalRevenue = 0D; Double totalCost = 0D; Double totalProfit = 0D; Query q1; q1 = em.createQuery("select i from PurchaseEntity i"); Query q2; q2 = em.createQuery("select i from ItemEntity i"); System.out.print("2"); List<ItemEntity> itemList = q2.getResultList(); List<PurchaseEntity> purchaseList = q1.getResultList(); System.out.print("3"); startMonth -= 1; endMonth -= 1; for (ItemEntity i : itemList) { Integer sales = 0; Double revenue = 0D; Double cost = 0D; for (PurchaseEntity p : purchaseList) { if ((p.getPurchasedDate().get(Calendar.YEAR) >= startYear) && (p.getPurchasedDate().get(Calendar.YEAR) <= endYear) && (p.getPurchasedDate().get(Calendar.MONTH) >= startMonth) && (p.getPurchasedDate().get(Calendar.MONTH) <= endMonth)) { System.out.print("looploop1"); Long orderId = p.getOrderId(); OrderEntity order = em.find(OrderEntity.class, orderId); ItemEntity item = em.find(ItemEntity.class, order.getItemId()); System.out.print("looploop2"); if (item.getId().equals(i.getId())) { sales += p.getQuantity(); revenue += p.getTotalPrice(); cost += p.getQuantity() * item.getCost(); System.out.print("looploop3"); } } } Double profit = revenue - cost; totalSales += sales; totalRevenue += revenue; totalCost += cost; totalProfit += profit; table.addCell(i.getId().toString()); table.addCell(i.getItemName()); table.addCell(sales.toString()); table.addCell(revenue.toString()); table.addCell(cost.toString()); table.addCell(profit.toString()); } document.add(table); document.add(new Paragraph( "--------------------------------------------------------------------------------------------------------------------------")); PdfPTable table2 = new PdfPTable(6); table2.getDefaultCell().setBorder(0); table2.addCell(" "); table2.addCell(" "); table2.addCell(totalSales.toString()); table2.addCell(totalRevenue.toString()); table2.addCell(totalCost.toString()); table2.addCell(totalProfit.toString()); document.add(table2); document.add(new Paragraph( "--------------------------------------------------------------------------------------------------------------------------")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Copyright 2015 All rights reserved | WineXpress", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, BaseColor.BLACK))); document.close(); FileOutputStream fos = new FileOutputStream(RESULT); fos.write(baos.toByteArray()); fos.close(); System.out.println("created"); Calendar generatedTime = Calendar.getInstance(); ReportEntity report = new ReportEntity("GeneralReport-" + reportTile, "G", RESULT, generatedTime); em.persist(report); em.flush(); } catch (Exception e) { } }
From source file:SessionBean.ReportMgt.ReportMgtBean.java
License:Open Source License
public void createProductReport(Long productId, Integer startYear, Integer startMonth, Integer endYear, Integer endMonth) {//from ww w . j a v a 2s . c om try { System.out.print("start"); ItemEntity item = em.find(ItemEntity.class, productId); String RESULT; String reportTitle; if (startYear.equals(endYear) && startMonth.equals(endMonth)) { RESULT = "d:/ProductReport-" + item.getId() + "-" + startYear + "." + startMonth + ".pdf"; reportTitle = startYear + "." + startMonth; } else { RESULT = "d:/ProductReport-" + item.getId() + "-" + startYear + "." + startMonth + "-" + endYear + "." + endMonth + ".pdf"; reportTitle = startYear + "." + startMonth + "-" + endYear + "." + endMonth; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); Document document = new Document(); PdfWriter.getInstance(document, baos); document.open(); Image image = Image.getInstance("d:/logo-4227.png"); image.scaleAbsolute(150, 50); document.add(image); document.add(new Paragraph("WineXpress Product Sales Report", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.BLACK))); document.add(new Paragraph("Item " + item.getId() + ": " + item.getItemName() + ", " + item.getVitage(), FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.RED))); document.add(new Paragraph("Generated Time: " + new Date().toString(), FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.PLAIN, BaseColor.BLACK))); document.add(new Paragraph(" ")); document.add(new Paragraph( "--------------------------------------------------------------------------------------------------------------------------")); PdfPTable table = new PdfPTable(5); table.getDefaultCell().setBorder(0); // PdfPCell cell= new PdfPCell(new Paragraph("Wine Name")); // cell.setColspan(4); // cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setBackgroundColor(BaseColor.BLACK); // table.addCell(cell); table.addCell("Period"); table.addCell("Sales"); table.addCell("Revenue"); table.addCell("Cost"); table.addCell("Profit"); table.addCell(" "); table.addCell("(bottle)"); table.addCell("(SGD)"); table.addCell("(SGD)"); table.addCell("(SGD)"); Integer totalSales = 0; Double totalRevenue = 0D; Double totalCost = 0D; Double totalProfit = 0D; Query q1; q1 = em.createQuery("select i from PurchaseEntity i"); Query q2; q2 = em.createQuery("select i from ItemEntity i"); System.out.print("2"); List<ItemEntity> itemList = q2.getResultList(); List<PurchaseEntity> purchaseList = q1.getResultList(); System.out.print("3"); for (int y = startYear; y <= endYear; y++) { for (int m = startMonth - 1; m <= endMonth - 1; m++) { Integer sales = 0; Double revenue = 0D; Double cost = 0D; System.out.print("loop"); for (PurchaseEntity p : purchaseList) { System.out.print("looploop1"); Long orderId = p.getOrderId(); OrderEntity order = em.find(OrderEntity.class, orderId); ItemEntity item1 = em.find(ItemEntity.class, order.getItemId()); System.out.print("looploop2"); if (item1.getId().equals(item.getId()) && p.getPurchasedDate().get(Calendar.MONTH) == m && p.getPurchasedDate().get(Calendar.YEAR) == y) { sales += p.getQuantity(); revenue += p.getTotalPrice(); cost += p.getQuantity() * item.getCost(); System.out.print("looploop3"); } } Double profit = revenue - cost; totalSales += sales; totalRevenue += revenue; totalCost += cost; totalProfit += profit; int n = m + 1; table.addCell(y + "-" + n); table.addCell(sales.toString()); table.addCell(revenue.toString()); table.addCell(cost.toString()); table.addCell(profit.toString()); } } document.add(table); document.add(new Paragraph( "--------------------------------------------------------------------------------------------------------------------------")); PdfPTable table2 = new PdfPTable(5); table2.getDefaultCell().setBorder(0); table2.addCell(" "); table2.addCell(totalSales.toString()); table2.addCell(totalRevenue.toString()); table2.addCell(totalCost.toString()); table2.addCell(totalProfit.toString()); document.add(table2); document.add(new Paragraph( "--------------------------------------------------------------------------------------------------------------------------")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Copyright 2015 All rights reserved | WineXpress", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, BaseColor.BLACK))); document.close(); FileOutputStream fos = new FileOutputStream(RESULT); fos.write(baos.toByteArray()); fos.close(); System.out.println("created"); Calendar generatedTime = Calendar.getInstance(); ReportEntity report = new ReportEntity("ProductReport-" + item.getId() + "-" + reportTitle, item.getId().toString(), RESULT, generatedTime); em.persist(report); em.flush(); } catch (Exception e) { } }