CrazyEngineers Archive
Old, but evergreen and popular discussions on CrazyEngineers, presented to you in read-only mode.
@krishbcs • 03 Apr, 2013
hi

i need to create pdf for my data from orcle database using java. i am using following java coding

import java.io.*;
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();
}
}
but it makes these of errors

--------------------Configuration: <Default>--------------------
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.
And also i download itextpdf-5.1.0 jar file. i don't know how i cleared this error.

please answer me.
@rahul69 • 03 Apr, 2013 Looks like the library you are using (ie itextpdf ) is not accessible to your program.
So add the library to the project classpath properly.
@krishbcs • 03 Apr, 2013 please tell me how i add the library to the project class properly
@Anand Tamariya • 03 Apr, 2013
krishbcs
please tell me how i add the library to the project class properly
java -help (hint: start exploring options)
@rahul69 • 04 Apr, 2013
krishbcs
please tell me how i add the library to the project class properly
Check out this link: here
@cathyhill • 13 Feb, 2014
krishbcs
hi

i need to create pdf for my data from orcle database using java. i am using following java coding
I think you have to mark sure that you have get the permission to use the library.
@moksh • 19 Feb, 2014 I have been using a 3rd party API from Jasper soft called Ireports ...it has extensive support for java ...code and tutorials are extensively available .... so far its the beswt opensource tool for pdf HTML and CSV reports..

Enjoy
3.5k views

Related Posts

@imgopi · Sep 4, 2011

Hi am fresher doing btech(cse) i want to join in infosys plz help me to get success in interview.
5.6k views

@rengaraj · Nov 25, 2009

Sir / madam, My question is A 1 KM long wire is held by 'n' poles. If one pole is removed the length of the gap increases by 5/3 meters....
4.8k views

@Kaustubh Katdare · Jan 14, 2014

Let us quickly have a round of posting for CDAC preferred centers by all the applicants. I found the following list from one of the members :-1.CDAC PUNE2 KP3.Sunbeam Gultekdi...
8.4k views

@keeping trying · Apr 8, 2009

- hello , I have assignment and there is the following question in it Actually I answered some of them but I am not sure I Drew the circuit and...
5.9k views

@sangee · Aug 11, 2009

hai, i'm doin my 3rd year(ece).suggest me any ideas for the mini-project please.............
5.2k views