Results 1 to 3 of 3
  1. #1
    shihad_s is offline Member
    Join Date
    Dec 2010
    Posts
    14
    Rep Power
    0

    Default generate pdf in servlet using itext library

    Hi,
    When i use itext library to generate pdf in servlet, i got an exception.
    ---------------------------------------------------------------------
    java.lang.NoClassDefFoundError: com/lowagie/text/DocumentException
    java.lang.Class.getDeclaredConstructors0(Native Method)
    java.lang.Class.privateGetDeclaredConstructors(Cla ss.java:2389)
    java.lang.Class.getConstructor0(Class.java:2699)
    java.lang.Class.newInstance0(Class.java:326)
    java.lang.Class.newInstance(Class.java:308)
    banking.ControllerServlet.doGet(ControllerServlet. java:74)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:617)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:717)

    ---------------------------------------------------------------------
    I added the itext jar files. Still i am getting the same exception. Any one please Help Me..

    My servlet code is added below:

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    response.setContentType("application/pdf");


    Document document = new Document();
    try{
    PdfWriter.getInstance(document, response.getOutputStream());
    document.open();


    PdfPTable table = new PdfPTable(2);
    table.addCell("1");
    table.addCell("2");
    table.addCell("3");
    table.addCell("4");
    table.addCell("5");
    table.addCell("6");


    document.add(table);
    document.close();
    }catch(DocumentException e){
    e.printStackTrace();
    }

    }
    ------------------------------------------------------------------

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    Is the jar on the Runtime classpath?
    In other words, is it in your WEB-INF/lib directory when deployed to the server?

  3. #3
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    450
    Rep Power
    7

    Default

    Tolls already hit the nail on the head. No more reason.
    Mak
    (Living @ Virtual World)

Similar Threads

  1. Merge 2 pdf files with itext and preview on servlet
    By xampos20 in forum New To Java
    Replies: 1
    Last Post: 05-12-2010, 12:49 AM
  2. Itext
    By anilhk@gmail.com in forum Advanced Java
    Replies: 0
    Last Post: 04-14-2010, 06:03 AM
  3. I want to put the native library in library path in mac os x
    By Hussain Ali in forum Advanced Java
    Replies: 2
    Last Post: 02-24-2010, 08:55 AM
  4. Tell me jar file for library library org.bouncycastle.cms
    By 82rathi.angara in forum New To Java
    Replies: 10
    Last Post: 09-09-2008, 06:11 AM
  5. iText 2.1.0
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 03-29-2008, 02:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •