Results 1 to 2 of 2
  1. #1
    eswaraaa is offline Member
    Join Date
    Dec 2009
    Rep Power

    Default I want to generate PDF report for student details?

    I am did code to generate pdf report for student details.. this code is working fine.. but i want to increase the table size.. the actual desing is not looking good.. can anybody change my code to help me..

    else if(reportType.equalsIgnoreCase("pdf")){
    System.out.println("its in inside the pdf");
    Document document = new Document(PageSize.LEDGER,100, 50, 80, 25);
    PdfWriter.getInstance(document, outObj);;
    document.add(new Paragraph("Student Report"));
    System.out.println("student row size.."+studentRowSize);
    Table tb = new Table(14,studentRowSize);

    Cell c = new Cell("S.No");
    tb.addCell(new Cell("A.NO"));
    tb.addCell(new Cell("STUDENT NAME"));
    tb.addCell(new Cell("FATHER NAME"));
    tb.addCell(new Cell("FATHER OCCUPATION"));
    tb.addCell(new Cell("MOTHER TONGUE"));
    tb.addCell(new Cell("CLASS NAME"));
    tb.addCell(new Cell("SECTION NAME"));
    tb.addCell(new Cell("FAMILY INCOME"));
    tb.addCell(new Cell("PERMANENT ADDRS"));
    tb.addCell(new Cell("TEMPORARY ADDRS"));
    tb.addCell(new Cell("CONTACT NUMBER"));
    tb.addCell(new Cell("EMEGENCY NUMBER"));
    tb.addCell(new Cell("EMAIL ID"));
    tb.addCell(new Cell("STUDENT STATUS"));

    for(int i=0;i<studentRowSize;i++){
    ArrayList student=(ArrayList)studentDetails.get(i);
    tb.addCell(new Cell((String)student.get(0)));
    tb.addCell(new Cell((String)student.get(1)));
    tb.addCell(new Cell((String)student.get(2)));
    tb.addCell(new Cell((String)student.get(3)));
    tb.addCell(new Cell((String)student.get(4)));
    tb.addCell(new Cell((String)student.get(5)));
    tb.addCell(new Cell((String)student.get(6)));
    tb.addCell(new Cell((String)student.get(7)));
    tb.addCell(new Cell((String)student.get(8)));
    tb.addCell(new Cell((String)student.get(9)));
    tb.addCell(new Cell((String)student.get(10)));
    tb.addCell(new Cell((String)student.get(11)));
    tb.addCell(new Cell((String)student.get(12)));
    tb.addCell(new Cell((String)student.get(13)));



    Thanks Advance..


  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Rep Power


    So what i sometimes do is nest or group the pieces of code that are related to one thing, to help make it at least visually appear to be organized a bit.

    Another idea here, to create a kind of static method that you would pass in an array or list of values, and it would then iterate over the list to do the same operation. in your case this might be helpful if rendering the same kind of data many times in different tables in the same report. but usually this kind of organizing just moves the many lines of code around and doesn't reduce them.

    unfortunately that iText API is pretty verbose. I keep meaning to get around to one day creating a kind of HTML or XML meta input language, that would be a kind of common pdf generating engine. I would feed it the high level commands like <table><tr><td>label</td></tr></table> and so on, and it would internally invoke the many individual formatting commands. but I also think the use of a tool like this would be very limited to the exact kinds of reports i am trying to do, everything would need to conform to a simple document convention. But also, I never have time to do this.

Similar Threads

  1. student need help
    By adamrain in forum New To Java
    Replies: 9
    Last Post: 11-29-2009, 12:10 AM
  2. How to generate report
    By Shivraj in forum NetBeans
    Replies: 0
    Last Post: 03-24-2009, 01:17 PM
  3. Generate Excel Report from a HTML table
    By Sudha in forum New To Java
    Replies: 0
    Last Post: 02-13-2008, 09:24 PM
  4. Student Help
    By mattwaab in forum Java Applets
    Replies: 0
    Last Post: 02-08-2008, 06:31 PM
  5. please help a student
    By jvasilj1 in forum New To Java
    Replies: 0
    Last Post: 02-01-2008, 02:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts