Hello, I installed JDK 1.5 and Tomcat 5.5 on a machine Windows, I also installed iText 2.0.1 (i get a jar file and zip source folder)so that I can print out pdf files, but when I compile the servelts containing the codes to print out pdf files, a message is posted saying that the classes called (Document, pdfWriter.....) do not exist.
Is it me which badly installed iText or there are other modifications to make?? How can i proceed?
Help me
Here is the code
import java.io.IOException;
import java.util.Date;
import java.lang.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class testpdf extends HttpServlet {
private static final long serialVersionUID = -6033026500372479591L;
public void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// step 1
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
try {
// step 2: we set the ContentType and create an instance of the corresponding Writer
response.setContentType("application/pdf");
PdfWriter.getInstance(document, response.getOutputStream());
// step 3
document.open();
// step 4
document.add(new Paragraph("Hello World"));
document.add(new Paragraph(new Date().toString()));
}
catch(DocumentException de) {
de.printStackTrace();
System.err.println("document: " + de.getMessage());
}
// step 5: we close the document (the outputstream is also closed internally)
document.close();
}
}