List of usage examples for com.itextpdf.text Document addCreationDate
public boolean addCreationDate()
From source file:PrintProjects.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {//ww w . j a v a 2 s . c om response.setContentType("Invoice.pdf"); //Get the output stream for writing PDF object OutputStream out = response.getOutputStream(); SystemDao dao = new SystemDao(); String username_dbase = getServletContext().getInitParameter("username"); String dbasepsw = getServletContext().getInitParameter("password"); String dbase = getServletContext().getInitParameter("jdbcConnection"); dao.open(username_dbase, dbasepsw, dbase); Document document = new Document(); /* Basic PDF Creation inside servlet */ ArrayList<User> users = dao.gettAllUsers(); //tithes ArrayList<Donation> list = dao.getAllDonations(); ArrayList<String> projects = dao.getProjects(); PdfWriter.getInstance(document, out); document.open(); document.addAuthor("LightHouse Chapel International"); document.addCreationDate(); document.addCreator("lci.com"); document.add(new Paragraph("============ PROJECTS ===========")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" NAME " + " " + " NUMBER ")); for (int x = 0; x < projects.size(); ++x) { String[] data = projects.get(x).split("@"); document.add(new Paragraph(" " + data[1] + " " + data[0])); } document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Total Donations : " + projects.size())); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.close(); } catch (Exception ex) { response.sendRedirect("systemError.jsp"); } }
From source file:PrintAll.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// w w w.j av a2 s .c o 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 { response.setContentType("Invoice.pdf"); //Get the output stream for writing PDF object OutputStream out = response.getOutputStream(); SystemDao dao = new SystemDao(); String username_dbase = getServletContext().getInitParameter("username"); String dbasepsw = getServletContext().getInitParameter("password"); String dbase = getServletContext().getInitParameter("jdbcConnection"); dao.open(username_dbase, dbasepsw, dbase); Document document = new Document(); /* Basic PDF Creation inside servlet */ ArrayList<User> users = dao.gettAllUsers(); //tithes ArrayList<Donation> list = dao.getAllDonations(); ArrayList<String> projects = dao.getProjects(); //donaations Vector<String> donations = dao.get_donation(); PdfWriter.getInstance(document, out); document.open(); document.addAuthor("LightHouse Chapel International"); document.addCreationDate(); document.addCreator("lci.com"); document.addTitle("USER INFORMATION SUMMARY"); document.add(new Paragraph("LightHouse Chapel International")); document.add(new Paragraph(" ")); document.add(new Paragraph("INFORMATION SUMMARY")); document.add(new Paragraph(" ")); document.add(new Paragraph("=========== TITHES ===============")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Amount " + " " + "Date ")); document.add(new Paragraph("")); double total = 0.00; for (int x = 0; x < list.size(); ++x) { total += list.get(x).getAmount(); document.add(new Paragraph(x + " " + list.get(x).getAmount() + " " + list.get(x).getDate())); } document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("============ USERS ===========")); document.add(new Paragraph(" ")); document.add(new Paragraph(" NAME " + " SURNAME " + " ACCOUNT NUMBER ")); for (User user : users) { document.add(new Paragraph(" " + user.getName() + " " + " " + user.getSurname() + " " + " " + user.getAccountNumber())); } document.add(new Paragraph(" ")); document.add(new Paragraph("============ PROJECTS ===========")); document.add(new Paragraph(" ")); document.add(new Paragraph(" NAME " + " NUMBER " + " COST ")); for (int x = 0; x < projects.size(); ++x) { String[] data = projects.get(x).split("@"); document.add(new Paragraph(" " + data[1] + " " + " " + data[0] + " " + " " + data[4])); } document.close(); } catch (Exception ex) { Logger.getLogger(PrintAll.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:PrintTitheReport.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from ww w.j ava2 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 { response.setContentType("Invoice.pdf"); //Get the output stream for writing PDF object OutputStream out = response.getOutputStream(); SystemDao dao = new SystemDao(); String username_dbase = getServletContext().getInitParameter("username"); String dbasepsw = getServletContext().getInitParameter("password"); String dbase = getServletContext().getInitParameter("jdbcConnection"); dao.open(username_dbase, dbasepsw, dbase); Document document = new Document(); /* Basic PDF Creation inside servlet */ ArrayList<User> users = dao.gettAllUsers(); //tithes ArrayList<Donation> list = dao.getAllDonations(); ArrayList<String> projects = dao.getProjects(); PdfWriter.getInstance(document, out); document.open(); document.addAuthor("LightHouse Chapel International"); document.addCreationDate(); document.addCreator("lci.com"); document.add(new Paragraph("=========== TITHES ===============")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Amount " + " " + "Date ")); document.add(new Paragraph("")); document.add(new Paragraph("")); double total = 0.00; for (int x = 0; x < list.size(); ++x) { total += list.get(x).getAmount(); document.add(new Paragraph( (1 + x) + " " + list.get(x).getAmount() + " " + list.get(x).getDate())); } 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("Total Number of people who paid tithe : " + list.size())); document.close(); } catch (Exception ex) { response.sendRedirect("systemError.jsp"); } }
From source file:PrintingServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w ww . ja v a 2 s. c o 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, DocumentException { try { response.setContentType("Invoice.pdf"); //Get the output stream for writing PDF object OutputStream out = response.getOutputStream(); SystemDao dao = new SystemDao(); String username_dbase = getServletContext().getInitParameter("username"); String dbasepsw = getServletContext().getInitParameter("password"); String dbase = getServletContext().getInitParameter("jdbcConnection"); dao.open(username_dbase, dbasepsw, dbase); Document document = new Document(); /* Basic PDF Creation inside servlet */ ArrayList<User> users = dao.gettAllUsers(); //tithes ArrayList<Donation> list = dao.getAllDonations(); ArrayList<String> projects = dao.getProjects(); //donaations Vector<String> donations = dao.get_donation(); PdfWriter.getInstance(document, out); document.open(); document.addAuthor("LightHouse Chapel International"); document.addCreationDate(); document.addCreator("lci.com"); document.addTitle("USER INFORMATION SUMMARY"); document.add(new Paragraph("LightHouse Chapel International")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("INFORMATION SUMMARY")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("=========== TITHES ===============")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("Amount " + " " + "Date ")); document.add(new Paragraph("")); document.add(new Paragraph("")); double total = 0.00; for (int x = 0; x < list.size(); ++x) { total += list.get(x).getAmount(); document.add(new Paragraph(x + " " + list.get(x).getAmount() + " " + list.get(x).getDate())); } document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("============ USERS ===========")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" NAME " + " SURNAME " + " ACCOUNT NUMBER ")); for (User user : users) { document.add(new Paragraph(" " + user.getName() + " " + " " + user.getSurname() + " " + " " + user.getAccountNumber())); } document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("============ PROJECTS ===========")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" NAME " + " NUMBER " + " COST ")); for (int x = 0; x < projects.size(); ++x) { String[] data = projects.get(x).split("@"); document.add(new Paragraph(" " + data[1] + " " + " " + data[0] + " " + " " + data[4])); } } catch (SQLException ex) { response.sendRedirect("systemError.jsp"); } catch (ClassNotFoundException ex) { response.sendRedirect("systemError.jsp"); } }
From source file:PrintDonations.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*from w ww . j ava2 s . com*/ * * @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 { response.setContentType("Invoice.pdf"); //Get the output stream for writing PDF object OutputStream out = response.getOutputStream(); SystemDao dao = new SystemDao(); String username_dbase = getServletContext().getInitParameter("username"); String dbasepsw = getServletContext().getInitParameter("password"); String dbase = getServletContext().getInitParameter("jdbcConnection"); dao.open(username_dbase, dbasepsw, dbase); Document document = new Document(); /* Basic PDF Creation inside servlet */ ArrayList<User> users = dao.gettAllUsers(); //tithes ArrayList<Donation> list = dao.getAllDonations(); ArrayList<String> projects = dao.getProjects(); //donaations Vector<String> donations = dao.get_donation(); PdfWriter.getInstance(document, out); document.open(); document.addAuthor("LightHouse Chapel International"); document.addCreationDate(); document.addCreator("lci.com"); document.add(new Paragraph(" ")); document.add(new Paragraph("============ PROJECTS ===========")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph("NAME" + " " + "NUMBER" + " " + "COST")); for (int x = 0; x < projects.size(); ++x) { String[] data = projects.get(x).split("@"); document.add(new Paragraph( " " + data[1] + " " + data[0] + " " + data[4])); } document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" Total Projects : " + projects.size())); document.add(new Paragraph(" ")); document.close(); } catch (Exception ex) { response.sendRedirect("systemError.jsp"); } }
From source file:PrintMaleMembers.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// w w w . j ava 2 s . c om * * @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 { response.setContentType("Invoice.pdf"); //Get the output stream for writing PDF object OutputStream out = response.getOutputStream(); SystemDao dao = new SystemDao(); String username_dbase = getServletContext().getInitParameter("username"); String dbasepsw = getServletContext().getInitParameter("password"); String dbase = getServletContext().getInitParameter("jdbcConnection"); dao.open(username_dbase, dbasepsw, dbase); Document document = new Document(); /* Basic PDF Creation inside servlet */ ArrayList<User> users = dao.gettAllUsers(); //tithes ArrayList<Donation> list = dao.getAllDonations(); ArrayList<String> projects = dao.getProjects(); //donaations Vector<String> donations = dao.get_donation(); PdfWriter.getInstance(document, out); document.open(); document.addAuthor("LightHouse Chapel International"); document.addCreationDate(); document.addCreator("lci.com"); document.addTitle("USER INFORMATION SUMMARY"); document.add(new Paragraph(" ")); document.add(new Paragraph("============ USERS ===========")); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" NAME " + " " + " SURNAME " + " " + " ACCOUNT NUMBER ")); for (User user : users) { document.add(new Paragraph(" " + user.getName() + " " + user.getSurname() + " " + user.getEmail())); } document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph(" Total Users : " + users.size())); document.add(new Paragraph(" ")); document.close(); } catch (Exception ex) { response.sendRedirect("systemError.jsp"); } }
From source file:adams.flow.transformer.PDFExtract.java
License:Open Source License
/** * Executes the flow item.//from w ww .ja va 2 s .co m * * @return null if everything is fine, otherwise error message */ @Override protected String doExecute() { String result; File file; int i; Document document; PdfCopy copy; PdfReader reader; int[] pages; int page; FileOutputStream fos; result = null; // get file if (m_InputToken.getPayload() instanceof File) file = (File) m_InputToken.getPayload(); else file = new PlaceholderFile((String) m_InputToken.getPayload()); fos = null; try { if (isLoggingEnabled()) getLogger().info("Extracting pages from '" + file + "' into '" + m_Output + "'"); document = new Document(); fos = new FileOutputStream(m_Output.getAbsolutePath()); copy = new PdfCopy(document, fos); document.open(); document.addCreationDate(); document.addCreator(Environment.getInstance().getProject()); document.addAuthor(System.getProperty("user.name")); reader = new PdfReader(file.getAbsolutePath()); if (isLoggingEnabled()) getLogger().info("- #pages: " + reader.getNumberOfPages()); m_Pages.setMax(reader.getNumberOfPages()); pages = m_Pages.getIntIndices(); for (i = 0; i < pages.length; i++) { page = pages[i] + 1; copy.addPage(copy.getImportedPage(reader, page)); if (isLoggingEnabled()) getLogger().info("- adding page: " + page); } copy.freeReader(reader); document.close(); } catch (Exception e) { result = handleException("Failed to extract pages: ", e); } finally { FileUtils.closeQuietly(fos); } if (result == null) m_OutputToken = new Token(m_Output.getAbsolutePath()); return result; }
From source file:adams.flow.transformer.PDFMerge.java
License:Open Source License
/** * Executes the flow item./*from w w w . j av a 2s.com*/ * * @return null if everything is fine, otherwise error message */ @Override protected String doExecute() { String result; PlaceholderFile[] files; int i; int n; int pages; Document document; PdfCopy copy; PdfReader reader; FileOutputStream fos; result = null; // get files files = FileUtils.toPlaceholderFileArray(m_InputToken.getPayload()); fos = null; try { if (isLoggingEnabled()) getLogger().info("Merging PDFs into: " + m_Output); document = new Document(); fos = new FileOutputStream(m_Output.getAbsolutePath()); copy = new PdfCopy(document, fos); document.open(); document.addCreationDate(); document.addCreator(Environment.getInstance().getProject()); document.addAuthor(System.getProperty("user.name")); for (i = 0; i < files.length; i++) { if (isLoggingEnabled()) getLogger().info("Adding file: " + files[i]); reader = new PdfReader(files[i].getAbsolutePath()); // loop over the pages in that document pages = reader.getNumberOfPages(); if (isLoggingEnabled()) getLogger().info("- #pages: " + pages); for (n = 1; n <= pages; n++) { copy.addPage(copy.getImportedPage(reader, n)); if (isLoggingEnabled()) getLogger().info("- adding page: " + n); } copy.freeReader(reader); } document.close(); } catch (Exception e) { result = handleException("Failed to merge PDF files: ", e); } finally { FileUtils.closeQuietly(fos); } if (result == null) m_OutputToken = new Token(m_Output.getAbsolutePath()); return result; }
From source file:be.thomasmore.service.CreatePDFServiceImp.java
@Override public void createPDF(List<Score> scores) { try {/*from w w w .ja va 2s . c o m*/ OutputStream file = new FileOutputStream(new File("D:\\Desktop\\Scores.pdf")); Document document = new Document(); PdfWriter.getInstance(document, file); document.open(); document.add(new Paragraph("Scores")); document.add(new Paragraph(new Date().toString())); document.addAuthor("Projectgroep 4"); document.addCreator("Projectgroep 4"); document.addTitle("ScoreTracker"); //Create Paragraph Paragraph paragraph = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD)); //New line paragraph.add(new Paragraph(" ")); paragraph.add("Scores"); paragraph.add(new Paragraph(" ")); document.add(paragraph); //Create a table in PDF PdfPTable pdftabel = new PdfPTable(4); PdfPCell cell1 = new PdfPCell(new Phrase("Student")); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); pdftabel.addCell(cell1); cell1 = new PdfPCell(new Phrase("Vak")); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); pdftabel.addCell(cell1); cell1 = new PdfPCell(new Phrase("Test")); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); pdftabel.addCell(cell1); cell1 = new PdfPCell(new Phrase("Score")); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); pdftabel.addCell(cell1); pdftabel.setHeaderRows(1); for (Score score : scores) { pdftabel.addCell(score.getStudent().getNaam()); pdftabel.addCell(score.getTest().getVak().getNaam()); pdftabel.addCell(score.getTest().getNaam()); int resultaat = score.getScore(); pdftabel.addCell(resultaat + " / " + score.getTest().getTotaal()); } document.add(pdftabel); document.addCreationDate(); document.close(); file.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:be.thomasmore.service.CreatePDFServiceImp.java
@Override public void createPDFVoorStudent(ArrayList<ArrayList<Score>> puntenlijst, List<Double> gemiddeldelijst, Double totaalGemiddelde) { try {/*w ww . jav a 2 s . co m*/ OutputStream file = new FileOutputStream(new File("D:\\Desktop\\Scores.pdf")); Document document = new Document(); PdfWriter.getInstance(document, file); document.open(); document.add(new Paragraph("Scores")); document.add(new Paragraph(puntenlijst.get(0).get(0).getStudent().getNaam())); document.add(new Paragraph(new Date().toString())); document.addAuthor("Projectgroep 4"); document.addCreator("Projectgroep 4"); document.addTitle("ScoreTracker"); //Create Paragraph Paragraph paragraph = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD)); //New line paragraph.add(new Paragraph(" ")); paragraph.add("Scores"); paragraph.add(new Paragraph(" ")); document.add(paragraph); for (int i = 0; i < puntenlijst.size(); i++) { //Create a table in PDF PdfPTable pdftabel = new PdfPTable(2); //vak invullen paragraph = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD)); paragraph.add(new Paragraph(puntenlijst.get(i).get(0).getTest().getVak().getNaam())); document.add(paragraph); PdfPCell cell1 = new PdfPCell(new Phrase("Test")); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); pdftabel.addCell(cell1); cell1 = new PdfPCell(new Phrase("Score")); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); pdftabel.addCell(cell1); pdftabel.setHeaderRows(1); for (Score score : puntenlijst.get(i)) { pdftabel.addCell(score.getTest().getNaam()); int resultaat = score.getScore(); pdftabel.addCell(resultaat + " / " + score.getTest().getTotaal()); } document.add(pdftabel); //gemmidelde per vak invoeren paragraph = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD)); paragraph.add(new Paragraph("Gemiddelde: " + gemiddeldelijst.get(i).toString())); document.add(paragraph); } paragraph = new Paragraph("", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD)); paragraph.add(new Paragraph("Algemeen gemiddelde: " + totaalGemiddelde)); document.add(paragraph); document.addCreationDate(); document.close(); file.close(); } catch (Exception e) { e.printStackTrace(); } }