List of usage examples for com.itextpdf.text Paragraph Paragraph
public Paragraph(Phrase phrase)
Paragraph
with a certain Phrase
. From source file:bodyfitness.relatorios.Relatorio.java
public void GeraRelatorioInadimplente(String caminho) { Document documento = new Document(); try {/* w w w .j ava 2s .co m*/ PdfWriter.getInstance(documento, new FileOutputStream(caminho + "/Adimplentes.pdf")); documento.open(); ClienteDAO dao = new ClienteDAO(); List<Cliente> clientes = dao.consultarInadimplentes(); PdfPTable tabela = new PdfPTable(2); tabela.addCell("ID"); tabela.addCell("Nome"); Paragraph p = new Paragraph(" Relatrio - Clientes Inadimplentes\n\n\n"); documento.add(p); for (Cliente c : clientes) { tabela.addCell(c.getId().toString()); tabela.addCell(c.getNome()); } documento.add(tabela); documento.close(); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Erro ao gerar documento:\n" + e.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE); } }
From source file:bodyfitness.relatorios.Relatorio.java
public void GeraRelatorioMaquinaSManutencao(String caminho) { Document documento = new Document(); try {//from www. j a va 2 s. com PdfWriter.getInstance(documento, new FileOutputStream(caminho + "/MaquinaSManutencao.pdf")); documento.open(); EquipamentoDAO dao = new EquipamentoDAO(); List<Equipamento> equips = dao.consultarSemManutancao(); PdfPTable tabela = new PdfPTable(3); tabela.addCell("ID"); tabela.addCell("Nome"); tabela.addCell("D. Ultima Mantencao"); SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy"); Paragraph p = new Paragraph(" Relatrio - Clientes Mquinas Sem Manuteno\n\n\n"); documento.add(p); for (Equipamento e : equips) { tabela.addCell(e.getId().toString()); tabela.addCell(e.getNome()); tabela.addCell(formato.format(e.getDataDaUltimaManutencao())); } documento.add(tabela); documento.close(); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Erro ao gerar documento:\n" + e.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE); } }
From source file:bodyfitness.relatorios.Relatorio.java
public void GeraRelatorioTreino(String caminho, Long id) { ClienteDAO cdao = new ClienteDAO(); Cliente cliente = cdao.consultarPorId(id); Document documento = new Document(); Paragraph p = new Paragraph("Nome: " + cliente.getNome() + "\n" + "Id: " + cliente.getId().toString() + "\n" + "Idade: " + cliente.getIdade().toString() + "\n\n"); PdfPTable tabela = new PdfPTable(3); tabela.addCell("Maquina"); tabela.addCell("Sries"); tabela.addCell("Repeties"); try {/*from w w w . j av a 2 s . c om*/ PdfWriter.getInstance(documento, new FileOutputStream(caminho + "/MaquinaSManutencao.pdf")); Treino t = cliente.getTreino(); for (int i = 0; i < t.getSeries().size(); i++) { tabela.addCell(t.getSeries().get(i).getEquipamento().getNome()); tabela.addCell(String.valueOf(t.getSeries().get(i).getQuantidadeDeSeries())); tabela.addCell(String.valueOf(t.getSeries().get(i).getRepeticoes())); } documento.add(p); documento.add(tabela); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Erro em relatrio de treino:\n" + e.getMessage()); } finally { documento.close(); } }
From source file:bodyfitness.relatorios.Relatorio.java
public void GeraRelatorioCondFisico(String caminho, Long id) { Document documento = new Document(); ClienteDAO cdao = new ClienteDAO(); Cliente c = cdao.consultarPorId(id); Paragraph p = new Paragraph("Nome: " + c.getNome() + "\n" + "Id: " + c.getId().toString() + "\n" + "Idade: " + c.getIdade().toString() + "\n\n"); try {// w ww .ja v a 2s . co m PdfWriter.getInstance(documento, new FileOutputStream(caminho + "/CondFisico.pdf")); documento.open(); PdfPTable tabela = new PdfPTable(2); tabela.addCell("Aspecto"); tabela.addCell("Valor"); //SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy"); CondicionamentoFisico cf = c.getCondicionamentoFisico(); tabela.addCell("IMC"); tabela.addCell(cf.getComposicaoCorporal().getImc().toString()); tabela.addCell("Massa Gorda"); tabela.addCell(cf.getComposicaoCorporal().getMassaGorda().toString()); tabela.addCell("Massa Magra"); tabela.addCell(cf.getComposicaoCorporal().getMassaMagra().toString()); tabela.addCell("Percentual atual de gordura"); tabela.addCell(cf.getComposicaoCorporal().getPercentualGorduraAtual().toString()); tabela.addCell("Percentual ideal de gordura"); tabela.addCell(cf.getComposicaoCorporal().getPercentualGorduraIdeal().toString()); tabela.addCell("Abdominal"); tabela.addCell(cf.getDobrasCutaneas().getAbdominal().toString()); tabela.addCell("Axilar Media"); tabela.addCell(cf.getDobrasCutaneas().getAxilarMedia().toString()); tabela.addCell("Bicipital"); tabela.addCell(cf.getDobrasCutaneas().getBicipital().toString()); tabela.addCell("Coxa"); tabela.addCell(cf.getDobrasCutaneas().getCoxa().toString()); tabela.addCell("Panturrilha"); tabela.addCell(cf.getDobrasCutaneas().getPanturrilha().toString()); tabela.addCell("Peitoral"); tabela.addCell(cf.getDobrasCutaneas().getPeitoral().toString()); tabela.addCell("Subescapular"); tabela.addCell(cf.getDobrasCutaneas().getSubescapular().toString()); tabela.addCell("Supra iliaca"); tabela.addCell(cf.getDobrasCutaneas().getSupraIliaca().toString()); tabela.addCell("Tricipital"); tabela.addCell(cf.getDobrasCutaneas().getTricipital().toString()); tabela.addCell("Antebrao Direito"); tabela.addCell(cf.getMembrosInferiores().getAnteBracoDireito().toString()); tabela.addCell("Brao Contrado Direito"); tabela.addCell(cf.getMembrosInferiores().getBracoContraidoDireito().toString()); tabela.addCell("Brao Relaxado Direito"); tabela.addCell(cf.getMembrosInferiores().getBracoRelaxadoDireito().toString()); tabela.addCell("Brao Relaxado Esquerdo"); tabela.addCell(cf.getMembrosInferiores().getBracoRelaxadoEsquerdo().toString()); tabela.addCell("Coxa Esquerda"); tabela.addCell(cf.getMembrosInferiores().getCoxaEsquerdo().toString()); tabela.addCell("Panturrilha Direita"); tabela.addCell(cf.getMembrosInferiores().getPanturrilhaDireito().toString()); tabela.addCell("Abdome"); tabela.addCell(cf.getMembrosSuperiores().getAbdome().toString()); tabela.addCell("Cintura"); tabela.addCell(cf.getMembrosSuperiores().getCintura().toString()); tabela.addCell("Ombro"); tabela.addCell(cf.getMembrosSuperiores().getOmbro().toString()); tabela.addCell("Pescoo"); tabela.addCell(cf.getMembrosSuperiores().getPescoco().toString()); tabela.addCell("Quadril"); tabela.addCell(cf.getMembrosSuperiores().getQuadril().toString()); tabela.addCell("Torx"); tabela.addCell(cf.getMembrosSuperiores().getToraxRelaxado().toString()); documento.add(p); documento.add(tabela); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Erro ao gerar documento:\n" + e.getMessage(), "Erro", JOptionPane.ERROR_MESSAGE); } finally { documento.close(); } }
From source file:bookshopautomationsoftware.GenerateReceipt.java
private static void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor("BILL DETAILS(Generated by BAS) on " + new Date(), catFont); // anchor.setName("First Chapter"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("CUSTOMER BILL", subFont); Section subCatPart = catPart.addSection(subPara); addEmptyLine(preface, 2);/* w ww . j a v a 2 s . c o m*/ // add a table createTable(subCatPart); Paragraph subPara2 = new Paragraph("Thanks for choosing us .. please visit again", subFont); Section subCatPart2 = catPart.addSection(subPara2); /* Anchor anchor2 = new Anchor("Thanks for choosing us .. please visit again", catFont); Chapter catPart2 = new Chapter(new Paragraph(anchor), 1);*/ // now add all this to the document document.add(catPart); //document.add(catPart2); }
From source file:bookstore.Report1.java
@Override public void generate() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true);//from w w w .j a va2 s.c o m DocumentBuilder builder; org.w3c.dom.Document doc = null; try { builder = factory.newDocumentBuilder(); doc = builder.parse("/Users/Anda/Documents/NetBeansProjects/Bookstore/book.xml"); // Create XPathFactory object XPathFactory xpathFactory = XPathFactory.newInstance(); // Create XPath object XPath xpath = xpathFactory.newXPath(); String title = model.getBookForReport(doc, xpath); String author = model.getBookAForReport(doc, xpath); Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("hello.pdf")); document.open(); document.add(new Paragraph("Titlul cartii care nu e pe stoc :" + title)); document.add(new Paragraph("Autorul cartii care nu e pe stoc :" + author)); document.close(); // System.out.println(author); //JOptionPane.showMessageDialog(null, "Autorul cartii este: "+author+"\nGenul: "+genre+"\nPretul: "+price+"\nCantitatea"+quan, null, JOptionPane.INFORMATION_MESSAGE); } catch (ParserConfigurationException | SAXException | IOException re) { re.printStackTrace(); } }
From source file:bouttime.report.award.AwardInventoryReport.java
License:Open Source License
/** * Generate an award report.//from w ww .ja va2 s. co m * @param dao Dao object to use to retrieve data. * @param session Session to generate the report for. * @param group Group to generate report for. This takes precedence, so * if not null, then the report will be generated for this group. * @return True if the report was generated. */ public static boolean doReport(Dao dao) { if (!dao.isOpen()) { logger.warn("DAO is not open"); return false; } if (dao.getMaxAward() == null) { logger.warn("Max Award value is NULL"); return false; } // step 1: creation of a document-object Document document = new Document(); try { // step 2: creation of the writer FileOutputStream fos = createOutputFile(); if (fos == null) { return false; } PdfWriter.getInstance(document, fos); // step 3: we open the document document.open(); // step 4: create and add content // create and add the header Paragraph p1 = new Paragraph(new Paragraph( String.format("%s %s %s, %s", dao.getName(), dao.getMonth(), dao.getDay(), dao.getYear()), FontFactory.getFont(FontFactory.HELVETICA, 10))); document.add(p1); Paragraph p2 = new Paragraph( new Paragraph("Award Inventory Report", FontFactory.getFont(FontFactory.HELVETICA, 14))); p2.setAlignment(Paragraph.ALIGN_CENTER); document.add(p2); PdfPTable datatable; int[] awardCounts = getAwardCountsForClassDivWeight(dao); if (awardCounts != null) { Paragraph p3 = new Paragraph(new Paragraph("\nFor class/age division/weight class", FontFactory.getFont(FontFactory.HELVETICA, 11))); p3.setAlignment(Paragraph.ALIGN_LEFT); document.add(p3); datatable = getDataTable(awardCounts, dao.getMaxAward()); document.add(datatable); } awardCounts = getAwardCountsForExistingGroups(dao); if (awardCounts != null) { Paragraph p3 = new Paragraph( new Paragraph("\nFor existing groups", FontFactory.getFont(FontFactory.HELVETICA, 11))); p3.setAlignment(Paragraph.ALIGN_LEFT); document.add(p3); datatable = getDataTable(awardCounts, dao.getMaxAward()); document.add(datatable); } } catch (DocumentException de) { logger.error("Document Exception", de); return false; } // step 5: we close the document document.close(); return true; }
From source file:bouttime.report.award.AwardReport.java
License:Open Source License
/** * Generate an award report.//from ww w.ja v a 2s .com * @param dao Dao object to use to retrieve data. * @param session Session to generate the report for. * @param group Group to generate report for. This takes precedence, so * if not null, then the report will be generated for this group. * @return True if the report was generated. */ private static boolean doReport(Dao dao, String session, Group group) { if (!dao.isOpen()) { return false; } // step 1: creation of a document-object Document document = new Document(); try { // step 2: creation of the writer FileOutputStream fos = createOutputFile(); if (fos == null) { return false; } PdfWriter.getInstance(document, fos); // step 3: we open the document document.open(); // step 4: create and add content // create and add the header Paragraph p1 = new Paragraph(new Paragraph( String.format("%s %s %s, %s", dao.getName(), dao.getMonth(), dao.getDay(), dao.getYear()), FontFactory.getFont(FontFactory.HELVETICA, 10))); document.add(p1); Paragraph p2 = new Paragraph( new Paragraph("Award Report", FontFactory.getFont(FontFactory.HELVETICA, 14))); p2.setAlignment(Paragraph.ALIGN_CENTER); document.add(p2); Font headerFont = new Font(Font.FontFamily.TIMES_ROMAN, 12); Font detailFont = new Font(Font.FontFamily.TIMES_ROMAN, 10); PdfPCell headerCell = new PdfPCell(); headerCell.setVerticalAlignment(Element.ALIGN_MIDDLE); headerCell.setPadding(3); headerCell.setBorderWidth(2); List<Group> groups; if (group != null) { groups = new ArrayList<Group>(); groups.add(group); } else if (session != null) { groups = dao.getGroupsBySession(session); } else { groups = dao.getAllGroups(); } for (Group g : groups) { // create and add the table PdfPTable datatable = new PdfPTable(4); int colWidths[] = { 30, 30, 30, 10 }; // percentage datatable.setWidths(colWidths); datatable.setWidthPercentage(100); datatable.getDefaultCell().setPadding(3); datatable.getDefaultCell().setBorderWidth(2); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); // The header has the group name headerCell.setPhrase(new Phrase(g.toString(), headerFont)); headerCell.setColspan(4); datatable.addCell(headerCell); datatable.setHeaderRows(1); // this is the end of the table header datatable.getDefaultCell().setBorderWidth(1); datatable.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); List<Wrestler> wList = getSortedAwardList(g); int i = 0; for (Wrestler w : wList) { if ((i++ % 2) == 0) { datatable.getDefaultCell().setGrayFill(0.9f); } else { datatable.getDefaultCell().setGrayFill(1); } datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); datatable.addCell(new Phrase(w.getFirstName(), detailFont)); datatable.addCell(new Phrase(w.getLastName(), detailFont)); datatable.addCell(new Phrase(w.getTeamName(), detailFont)); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); Integer place = w.getPlace(); String placeStr = (place == null) ? "" : place.toString(); datatable.addCell(new Phrase(placeStr, detailFont)); } datatable.setSpacingBefore(5f); datatable.setSpacingAfter(15f); document.add(datatable); } } catch (DocumentException de) { logger.error("Document Exception", de); return false; } // step 5: we close the document document.close(); return true; }
From source file:bouttime.report.boutsequence.BoutSequenceReport.java
License:Open Source License
private static void addHeader(Dao dao, Document document, String team, String session) throws DocumentException { Paragraph p1 = new Paragraph(new Paragraph( String.format("%s %s %s, %s", dao.getName(), dao.getMonth(), dao.getDay(), dao.getYear()), FontFactory.getFont(FontFactory.HELVETICA, 10))); document.add(p1);//from ww w . j ava2 s .c om String instructions = "1) The first bout is the first number found in square brackets '[ ]'.\n" + "2) If this bout is won, the next bout is the next number found in square brackets.\n" + "3) If a bout in square brackets is lost, the next bout is to the LEFT (unless Round Robin). From this point, go RIGHT-to-LEFT.\n"; if (dao.isFifthPlaceEnabled()) { instructions += "4) Fifth place bouts are in angle brackets '< >'.\n"; } Paragraph p2 = new Paragraph(new Paragraph(instructions, FontFactory.getFont(FontFactory.HELVETICA, 8))); document.add(p2); StringBuilder sb = new StringBuilder(team); if (session != null) { sb.append(" / Session : "); sb.append(session); } Paragraph p3 = new Paragraph(new Paragraph(sb.toString(), FontFactory.getFont(FontFactory.HELVETICA, 12))); document.add(p3); }
From source file:bouttime.report.matkey.MatKeyReport.java
License:Open Source License
/** * Generate the Mat Key report.//w w w. j av a 2 s . c om * This is a color-coded report that maps the groups to a mat. * @param dao Dao object to use to retrieve data. * @return True if the report was generated. */ public static boolean doReport(Dao dao) { if (!dao.isOpen()) { logger.warn("Cannot create report : DAO not open"); return false; } String matValues = dao.getMatValues(); if ((matValues == null) || matValues.isEmpty()) { JFrame mainFrame = BoutTimeApp.getApplication().getMainFrame(); JOptionPane.showMessageDialog(mainFrame, "Mat values are not configured." + "\nSet the mat values in 'Edit -> Configuration'", "Mat Key Report error", JOptionPane.WARNING_MESSAGE); logger.warn("Cannot create report : mat values not configured"); return false; } // step 1: creation of a document-object Document document = new Document(); try { // step 2: creation of the writer FileOutputStream fos = createOutputFile(); if (fos == null) { return false; } PdfWriter.getInstance(document, fos); // step 3: we open the document document.open(); // step 4: create and add content // create and add the header Paragraph p1 = new Paragraph(new Paragraph( String.format("%s %s %s, %s", dao.getName(), dao.getMonth(), dao.getDay(), dao.getYear()), FontFactory.getFont(FontFactory.HELVETICA, 10))); document.add(p1); Paragraph p2 = new Paragraph( new Paragraph("Mat Key Report", FontFactory.getFont(FontFactory.HELVETICA, 14))); p2.setAlignment(Paragraph.ALIGN_CENTER); document.add(p2); int cols = 4; // Class, Div, Weight, Mat // create and add the table PdfPTable datatable = new PdfPTable(cols); //int colWidths[] = { 55, 15, 15, 15 }; // percentage //datatable.setWidths(colWidths); datatable.getDefaultCell().setPadding(3); datatable.getDefaultCell().setBorderWidth(2); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell("Class"); datatable.addCell("Div"); datatable.addCell("Weight"); datatable.addCell("Mat"); datatable.setHeaderRows(1); // this is the end of the table header datatable.getDefaultCell().setBorderWidth(1); // Prepare the list of groups List<Group> groups = dao.getAllGroups(); Collections.sort(groups, new GroupClassDivWtSort()); // Prepare the list of mat values String[] mats = matValues.split(","); List<String> matList = new ArrayList<String>(); for (String m : mats) { matList.add(m.trim()); } for (Group g : groups) { String mat = g.getMat(); int idx = matList.indexOf(mat); datatable.getDefaultCell().setBackgroundColor(colorMap.get(idx)); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); datatable.addCell(g.getClassification()); datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); datatable.addCell(g.getAgeDivision()); datatable.addCell(g.getWeightClass()); datatable.addCell(g.getMat()); } datatable.setSpacingBefore(15f); // space between title and table document.add(datatable); } catch (DocumentException de) { logger.error("Document Exception", de); return false; } // step 5: we close the document document.close(); return true; }