1

i am trying to convert my html to pdf file in java using itext.i am using eclipse editor,i have add two jar file

     xmlworker-5.4.3.jar, 
     itextpdf-5.1.0.jar

in classpath.my code is given beloow

        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new 
        FileOutputStream("pdf.pdf"));
        document.open();
        XMLWorkerHelper.getInstance().parseXHtml(writer, document,new  
        FileInputStream("index.html"));
        System.out.println( "PDF Created!" );

when i run above code it gives me exception. i don't know how to solve it. my exception is given below

        Exception in thread "main" java.lang.NoSuchMethodError:  
        com.itextpdf.text.log.LoggerFactory.getLogger(Ljava/lang/Class;)Lcom/itextpdf
        /text/log/Loger;
        at com.itextpdf.tool.xml.net.FileRetrieveImpl.<clinit> 
          (FileRetrieveImpl.java:67)at com.itextpdf.tool.xml.css.StyleAttrCSSResolver. 
          <init>
        (StyleAttrCSSResolver.java:113)
        at com.itextpdf.tool.xml.css.StyleAttrCSSResolver.<init>  
         (StyleAttrCSSResolver.java:102)
         at com.itextpdf.tool.xml.css.StyleAttrCSSResolver.<init>
         (StyleAttrCSSResolver.java:90)
        at om.itextpdf.tool.xml.XMLWorkerHelper.parseXHtml(XMLWorkerHelper.java:213)
        at df.tool.xml.XMLWorkerHelper.parseXHtml(XMLWorkerHelper.java:185)
        at com.ps.App.main(App.java:47)

i think my error will at this place

   XMLWorkerHelper.getInstance().parseXHtml(writer, document,new  
        FileInputStream("index.html"));

Help me hove to solve this exception..... Thanks in advance.

1
  • I solve the Problem That's Why I am Going To close. Commented Apr 24, 2014 at 9:17

1 Answer 1

2

It seems versions of these jars are not compatible with each other. Try below versions and let us know xmlworker-5.4.5.jar, itextpdf-5.4.5.jar

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.