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
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!