Member • Apr 3, 2013
Problem in create Pdf using java
i need to create pdf for my data from orcle database using java. i am using following java coding
import java.io.*;but it makes these of errors
import java.sql.*;
import jpack.Database;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
public class pdf
{
public static void main(String arg[])throws Exception
{
Database db=new Database();
Document document=new Document();
PdfWriter.getInstance(document,new FileOutputStream("d:/item.pdf"));
document.open();
PdfPTable table=new PdfPTable(2);
table.addCell("ITEMID");
table.addCell("ITEMNAME");
ResultSet rs=db.Select("Select * from item");
while(rs.next())
{
table.addCell(rs.getString("ITEMID"));
table.addCell(rs.getString("ITEMNAME"));
}
document.add(table);
document.close();
}
}
--------------------Configuration:And also i download itextpdf-5.1.0 jar file. i don't know how i cleared this error.--------------------
C:\Documents and Settings\user\Desktop\Project\bala\DesignCodes\pdf.java:4: package com.itextpdf.text does not exist
import com.itextpdf.text.Document;
^
C:\Documents and Settings\user\Desktop\Project\bala\DesignCodes\pdf.java:5: package com.itextpdf.text does not exist
import com.itextpdf.text.Paragraph;
^
C:\Documents and Settings\user\Desktop\Project\bala\DesignCodes\pdf.java:6: package com.itextpdf.text.pdf does not exist
import com.itextpdf.text.pdf.PdfWriter;
^
C:\Documents and Settings\user\Desktop\Project\bala\DesignCodes\pdf.java:14: cannot find symbol
symbol : class Document
location: class pdf
Document document=new Document();
^
C:\Documents and Settings\user\Desktop\Project\bala\DesignCodes\pdf.java:14: cannot find symbol
symbol : class Document
location: class pdf
Document document=new Document();
^
C:\Documents and Settings\user\Desktop\Project\bala\DesignCodes\pdf.java:15: cannot find symbol
symbol : variable PdfWriter
location: class pdf
PdfWriter.getInstance(document,new FileOutputStream("d:/item.pdf"));
^
C:\Documents and Settings\user\Desktop\Project\bala\DesignCodes\pdf.java:17: cannot find symbol
symbol : class PdfPTable
location: class pdf
PdfPTable table=new PdfPTable(2);
^
C:\Documents and Settings\user\Desktop\Project\bala\DesignCodes\pdf.java:17: cannot find symbol
symbol : class PdfPTable
location: class pdf
PdfPTable table=new PdfPTable(2);
^
8 errors
Process completed.
please answer me.