/** * Ritorna la lista degli studenti iscritti ad un appello * * @param pAppello appello * @return lista di studenti iscritti */ public ArrayList<StudenteClass> getIscrittiAppello(Appello pAppello) { try { return mDBMSStampaIscrittiBnd.getIscrittiAppello(pAppello); } catch (SQLException e) { e.printStackTrace(); return null; } }
/** * Genera un pdf che contiene la lista di tutti gli studenti iscritti ad un appello * * @param pAppello informazioni appello * @throws Exception */ public void createDocument(Appello pAppello) throws Exception { Document document = new Document(); ArrayList<StudenteClass> listaIscritti = mDBMSStampaIscrittiBnd.getIscrittiAppello(pAppello); try { PdfWriter writer = PdfWriter.getInstance( document, new FileOutputStream("Elenco" + pAppello.getIdAppello() + ".pdf")); document.open(); document.add(new Paragraph("Lista Iscritti")); // Add ordered list List orderedList = new List(List.ORDERED); for (StudenteClass s : listaIscritti) orderedList.add(new ListItem(s.toString())); document.add(orderedList); document.close(); writer.close(); Desktop d = Desktop.getDesktop(); d.open(new File("Elenco" + pAppello.getIdAppello() + ".pdf")); } catch (Exception e) { e.printStackTrace(); } }