List of usage examples for com.itextpdf.text List ORDERED
boolean ORDERED
To view the source code for com.itextpdf.text List ORDERED.
Click Source Link
From source file:com.farouk.projectapp.ManagerGUI.java
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed String pdfName = JOptionPane.showInputDialog(rootPane, "Enter Title", "Please enter a title", WIDTH); if (pdfName.isEmpty()) { pdfName = "Global Report"; }//from w ww.j a va2 s. co m Document document = new Document(); int numEMployees = 1; try { PdfWriter.getInstance(document, new FileOutputStream(pdfName + ".pdf")); document.open(); document.addAuthor("TeamPirates"); document.addTitle("Global Report"); Font font1 = new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.BOLD); Font font2 = new Font(Font.FontFamily.TIMES_ROMAN, 15, Font.UNDERLINE); for (User u : SQLConnectMana.getEmployeesFromDb()) { JTable jTableTran = new JTable(); JTable jTableReport = new JTable(); Chapter chapter = new Chapter( new Paragraph(new Phrase("Employee : " + u.getLogin() + "\n\n", font1)), numEMployees); Section section1 = chapter.addSection(new Paragraph(new Phrase("Recent Transactions :\n", font2)), 9); Section section2 = chapter.addSection(new Paragraph(new Phrase("Reported Companies :\n", font2)), 9); // Transactions : DefaultTableModel modelPDFtrans = new DefaultTableModel(); modelPDFtrans.setColumnIdentifiers( new String[] { "Name", "Operation", "Quantity", "Price Paid", "Date" }); for (Transaction t : SQLConnectMana.getTransactions(u.getId())) { modelPDFtrans.addRow(new String[] { t.getSymbol(), t.getOperation(), Integer.toString(t.getQuantity()), Double.toString(t.getPricePaid()), t.getDate() }); } jTableTran.setModel(modelPDFtrans); PdfPTable pdfTableTrans = new PdfPTable(jTableTran.getColumnCount()); for (int i = 0; i < jTableTran.getColumnCount(); i++) { pdfTableTrans.addCell(jTableTran.getColumnName(i)); } //extracting data from the JTable and inserting it to PdfPTable for (int rows = 0; rows < jTableTran.getRowCount(); rows++) { for (int cols = 0; cols < jTableTran.getColumnCount(); cols++) { pdfTableTrans.addCell(jTableTran.getModel().getValueAt(rows, cols).toString()); } } Paragraph blank = new Paragraph("\n\n"); section1.add(blank); section1.add(pdfTableTrans); section1.add(blank); //Reported Companies : DefaultTableModel modelPDFReported = new DefaultTableModel(); modelPDFReported.setColumnIdentifiers( new String[] { "Name", "Symbol", "Stock Price ()", "Quantity Bought" }); for (Company c : SQLConnectMana.getNameOfReported(u.getId())) { modelPDFReported.addRow(new String[] { c.getName(), c.getSymbol(), String.valueOf(c.getStockPrice().doubleValue()), Integer.toString(c.getNumberOwned()) }); } jTableReport.setModel(modelPDFReported); PdfPTable pdfTableReport = new PdfPTable(jTableReport.getColumnCount()); for (int i = 0; i < jTableReport.getColumnCount(); i++) { pdfTableReport.addCell(jTableReport.getColumnName(i)); } //extracting data from the JTable and inserting it to PdfPTable for (int rows = 0; rows < jTableReport.getRowCount(); rows++) { for (int cols = 0; cols < jTableReport.getColumnCount(); cols++) { pdfTableReport.addCell(jTableReport.getModel().getValueAt(rows, cols).toString()); } } section2.add(blank); section2.add(pdfTableReport); section2.add(blank); //End of doc for a single employee document.add(chapter); numEMployees++; } Chapter ban = new Chapter(new Paragraph(new Phrase("Prohibited Companies :\n\n", font1)), ++numEMployees); com.itextpdf.text.List bannedCompanies = new List(List.ORDERED); for (String lii : SQLConnectMana.getBannedCompForAll()) { bannedCompanies.add(new com.itextpdf.text.ListItem(lii)); } ban.add(bannedCompanies); document.add(ban); document.close(); } catch (DocumentException | FileNotFoundException e) { System.err.println("Sorry Problem in pdf.\n" + e); } }
From source file:src.GUI.PDFGEN.java
License:Open Source License
public void PDFAB(String Headline, int AmountExer, GUISETTINGSPDF k) { Document Doc = new Document(); Rectangle Rec = new Rectangle(PageSize.A4); Doc.setPageSize(Rec);//w ww . j a v a2s . c o m try { F = File.createTempFile("Blatt", ".pdf"); PdfWriter.getInstance(Doc, new FileOutputStream(F)); Doc.open(); Paragraph Para = new Paragraph(Headline, FONTS.FontHeader()); Para.setAlignment(Element.ALIGN_CENTER); Doc.add(Para); First = new MEMORY(); Current = First; GUISETTINGSPDF D = k; //Image Img = Image.getInstance("Logo"); //Doc.add(Img); for (int i = 1; i <= AmountExer; i++) { List = new List(List.ORDERED, List.ALPHABETICAL); for (int c = 0; c < k.taskNumber; c++) { TERM Term = new TERM(k.aoAddition, k.aoSubtraction, k.aoMultiplication, k.aoDivision, k.bracketDepht, k.Substitutions, k.Digits, k.decimalPlaces, k.justPositive); Current.writeExercise(Term.infix() + "="); Current.writeSolution(Double.parseDouble(Term.getSolution())); List.add(new ListItem(Current.readExercise())); Current.Next = new MEMORY(); Current = Current.Next; } Doc.add(new Paragraph(" \n Aufgabe " + i, FONTS.Font())); k = k.next; Doc.add(List); } Doc.close(); Desktop.getDesktop().open(F); PDFLB(AmountExer, D); Desktop.getDesktop().open(G); } catch (Exception e) { e.printStackTrace(); } }
From source file:src.GUI.PDFGEN.java
License:Open Source License
private void PDFLB(int AmountExer, GUISETTINGSPDF k) { Document Doc = new Document(); Rectangle Rec = new Rectangle(PageSize.A4); Doc.setPageSize(Rec);//from ww w . ja v a 2 s. c om try { G = File.createTempFile("Blatt", ".pdf"); PdfWriter.getInstance(Doc, new FileOutputStream(G)); Doc.open(); Paragraph Para = new Paragraph("Lsungsblatt", FONTS.FontHeader()); Para.setAlignment(Element.ALIGN_CENTER); Doc.add(Para); for (int i = 1; i <= AmountExer; i++) { List = new List(List.ORDERED, List.ALPHABETICAL); for (int c = 0; c < k.taskNumber; c++) { String S = First.readExercise() + First.readSolution(); List.add(new ListItem(S)); First = First.Next; } Doc.add(new Paragraph(" \n Aufgabe" + i, FONTS.Font())); Doc.add(List); k = k.next; } Doc.close(); } catch (Exception e) { e.printStackTrace(); } }