title: java.lang.NoClassDefFoundError: com/itextpdf/kernel/counter/event/IMetaInfo
body: <p>I'm new to Java, I'm working on generating pdf from html. Therefore, I'm using the iText7, I can generate a normal pdf file through PdfWriter and Document but I can't do it using html2pdf.</p>
  
  <p>Here is my Pom.xml</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
    &lt;groupId&gt;springexample&lt;/groupId&gt;
    &lt;artifactId&gt;PDFGenerator&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
  
    &lt;name&gt;bean&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
    &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
    &lt;/properties&gt;
  
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;!-- https://mvnrepository.com/artifact/com.itextpdf/itext7-core --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.itextpdf&lt;/groupId&gt;
          &lt;artifactId&gt;itext7-core&lt;/artifactId&gt;
          &lt;version&gt;7.0.4&lt;/version&gt;
          &lt;type&gt;pom&lt;/type&gt;
      &lt;/dependency&gt;
  
      &lt;!-- https://mvnrepository.com/artifact/com.itextpdf/itext7-core --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.itextpdf&lt;/groupId&gt;
          &lt;artifactId&gt;kernel&lt;/artifactId&gt;
          &lt;version&gt;7.0.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.itextpdf&lt;/groupId&gt;
          &lt;artifactId&gt;io&lt;/artifactId&gt;
          &lt;version&gt;7.0.4&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.itextpdf&lt;/groupId&gt;
          &lt;artifactId&gt;layout&lt;/artifactId&gt;
          &lt;version&gt;7.0.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.itextpdf&lt;/groupId&gt;
          &lt;artifactId&gt;forms&lt;/artifactId&gt;
          &lt;version&gt;7.0.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.itextpdf&lt;/groupId&gt;
          &lt;artifactId&gt;pdfa&lt;/artifactId&gt;
          &lt;version&gt;7.0.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.itextpdf&lt;/groupId&gt;
          &lt;artifactId&gt;pdftest&lt;/artifactId&gt;
          &lt;version&gt;7.0.4&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- https://mvnrepository.com/artifact/com.itextpdf/html2pdf --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.itextpdf&lt;/groupId&gt;
          &lt;artifactId&gt;html2pdf&lt;/artifactId&gt;
          &lt;version&gt;2.1.4&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
          &lt;version&gt;1.7.26&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>and here is my code java:</p>
  
  <pre><code>import java.io.FileOutputStream;
  import java.io.IOException;
  import java.nio.file.Paths;
  
  import com.itextpdf.html2pdf.HtmlConverter;
  
  public class HtmlToPdf {
  
  /** The HTML-string that we are going to convert to PDF. */
  public static final String HTML = "&lt;h1&gt;Test&lt;/h1&gt;&lt;p&gt;Hello World&lt;/p&gt;";
  /** The target folder for the result. */
  public static final String TARGET = "target/";
  /** The path to the resulting PDF file. */
  public static final String DEST = String.format("%stest-01.pdf", TARGET);
  
          public static void main(String[] args) throws IOException { 
  
              HtmlConverter.convertToPdf(HTML, new FileOutputStream(DEST));
  
              System.out.println("Done");
          }
      }
  </code></pre>
  
  <p>The error is on the line: </p>
  
  <pre><code>HtmlConverter.convertToPdf(HTML, new FileOutputStream(DEST));
  </code></pre>
  
  <hr>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: com/itextpdf/kernel/counter/event/IMetaInfo
      at springexample.bean.HtmlToPdf.main(HtmlToPdf.java:18)
  Caused by: java.lang.ClassNotFoundException: com.itextpdf.kernel.counter.event.IMetaInfo
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
  </code></pre>
  
  <p>I read other issues related to </p>
  
  <blockquote>
    <p>java.lang.NoClassDefFoundError</p>
  </blockquote>
  
  <p>they said that I need to add the io and slf4j dependencies, however the error remains.
  Thanks in advance.</p>