How do I generate reports in Java?

18,002

Solution 1

Well, first of all, if you don't want to use any of the java PDF/reporting libraries, you have to understand what is a PDF.

Start here with an article about the structure of a PDF, then go here for the complete, raw reference of the PDF format.

Hint: this is very hard. PDF is a print/display-oriented format and really complex. Another option is generating an HTML and using some tool to generate the PDF in the end. This is usually easier, as HTML is a far simpler format than PDF.

HTH!

Solution 2

Try itex API. To use IText PDF API for Java you must first download the IText JAR file from the IText website (http://itextpdf.com/), and include it on your application class path:

http://tutorials.jenkov.com/java-itext/getting-started.html

Share:
18,002
user2525364
Author by

user2525364

Updated on July 18, 2022

Comments

  • user2525364
    user2525364 almost 2 years

    How do I generate reports in Java using IO?

    I want to generate PDF files with database records.

    At the moment I have something like this...

    try{
        ResultSet rs = ps.executeQuery();
        while(rs.next()){
        FileOutputStream fos = new FileOutputStream("Desktop/Test.pdf");
        ObjectOutputStream out = new ObjectOutputStream(fos);
        out.writeChars("Name of user: ");
        out.writeChars("Age: ");
        out.close();
    }
    }
        catch (IOException ioe){
        }
    

    It keeps saying that the PDF file is corrupted.

    I would greatly appreciate it if someone could help me out here.

    Edit: I do not want to use iReports/JasperReports/iText/other report generators.

    Many thanks