
Good afternoon,
I have a problem how to create report. i want to create report in pdf file from my database in mysql. Now i use IReport too create pdf file, can't work...., pleas tell me a tutorial/source code to create pdf file from database call from java programming.
thank you,
Hendra

Create PDF from Java
import java.io.*;
import java.sql.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
public class CreatePDF{
public static void main(String arg[])throws Exception{
Document document=new Document();
PdfWriter.getInstance(document,new FileOutputStream("C:/data.pdf"));
document.open();
PdfPTable table=new PdfPTable(2);
table.addCell("Name");
table.addCell("Address");
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from data");
while(rs.next()){
table.addCell(rs.getString("name"));
table.addCell(rs.getString("address"));
}
document.add(table);
document.close();
}
}
For more information, visit the following link:

i have a problem again, please help me again....., i have a case, where my data is much field. i have 12 field, and my data have 10-30 character and more in 1 field. can you help me how to resize my data is good looking if i print in pdf. maybe make a landscape preview, thank you
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.