Results 1 to 2 of 2
  1. #1
    Aminaz is offline Member
    Join Date
    Apr 2012
    Location
    Algeria
    Posts
    3
    Rep Power
    0

    Default NoClassDefFound error using PDFBox

    Hello everybody, here is my codesource of reading a pdf file :
    public static String getString(String file) throws IOException{
    String Text = "" ;
    PDDocument doc = null;
    try {
    doc = PDDocument.load("C:/Users/USER/workspace/Wordnet/src/pdf/"+file);
    PDFTextStripper stripper = new PDFTextStripper();
    Text =stripper.getText(doc);
    } finally {
    if (doc != null) {
    doc.close();
    }
    }
    return Text;
    }
    but it's not work with all files for example articles using diffrent fonts and sizes of writing comback tp me with this error:
    29 avr. 2012 08:30:07 org.apache.pdfbox.util.PDFStreamEngine processEncodedText
    ATTENTION: java.lang.NoClassDefFoundError: org/apache/fontbox/afm/AFMParser
    java.lang.NoClassDefFoundError: org/apache/fontbox/afm/AFMParser
    at org.apache.pdfbox.pdmodel.font.PDFont.getAFM(PDFon t.java:329)
    at org.apache.pdfbox.pdmodel.font.PDFont.getFontWidth FromAFMFile(PDFont.java:262)
    at org.apache.pdfbox.pdmodel.font.PDSimpleFont.getFon tWidth(PDSimpleFont.java:175)
    at org.apache.pdfbox.util.PDFStreamEngine.processEnco dedText(PDFStreamEngine.java:323)
    at org.apache.pdfbox.util.operator.ShowTextGlyph.proc ess(ShowTextGlyph.java:61)
    at org.apache.pdfbox.util.PDFStreamEngine.processOper ator(PDFStreamEngine.java:552)
    at org.apache.pdfbox.util.PDFStreamEngine.processSubS tream(PDFStreamEngine.java:248)
    at org.apache.pdfbox.util.PDFStreamEngine.processStre am(PDFStreamEngine.java:207)
    at org.apache.pdfbox.util.PDFTextStripper.processPage (PDFTextStripper.java:367)
    at org.apache.pdfbox.util.PDFTextStripper.processPage s(PDFTextStripper.java:291)
    at org.apache.pdfbox.util.PDFTextStripper.writeText(P DFTextStripper.java:247)
    at PDFTest.main(PDFTest.java:22)
    Caused by: java.lang.ClassNotFoundException: org.apache.fontbox.afm.AFMParser
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    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)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    ... 12 more
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/fontbox/afm/AFMParser
    at org.apache.pdfbox.pdmodel.font.PDFont.getAFM(PDFon t.java:329)
    at org.apache.pdfbox.pdmodel.font.PDFont.getAverageFo ntWidthFromAFMFile(PDFont.java:282)
    at org.apache.pdfbox.pdmodel.font.PDSimpleFont.getAve rageFontWidth(PDSimpleFont.java:222)
    at org.apache.pdfbox.util.PDFStreamEngine.processEnco dedText(PDFStreamEngine.java:331)
    at org.apache.pdfbox.util.operator.ShowTextGlyph.proc ess(ShowTextGlyph.java:61)
    at org.apache.pdfbox.util.PDFStreamEngine.processOper ator(PDFStreamEngine.java:552)
    at org.apache.pdfbox.util.PDFStreamEngine.processSubS tream(PDFStreamEngine.java:248)
    at org.apache.pdfbox.util.PDFStreamEngine.processStre am(PDFStreamEngine.java:207)
    at org.apache.pdfbox.util.PDFTextStripper.processPage (PDFTextStripper.java:367)
    at org.apache.pdfbox.util.PDFTextStripper.processPage s(PDFTextStripper.java:291)
    at org.apache.pdfbox.util.PDFTextStripper.writeText(P DFTextStripper.java:247)
    at PDFTest.main(PDFTest.java:22)
    Could you please help me to figure out what is the problem?????????? Thank you

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: NoClassDefFound error using PDFBox

    Removed from PDFBox Problem

    1. When you have a question start your own thread -- they're free. Don't post in an old dead thread and don't hijack another poster's thread.
    2. Go through these pages:
    BB Code List - Java Programming Forum
    Guide For New Members
    http://www.java-forums.org/content/113-forum-rules.html

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 4
    Last Post: 07-24-2011, 08:52 AM
  2. java.lang.NoClassDefFound error
    By swathi dharmaraj in forum New To Java
    Replies: 11
    Last Post: 04-14-2011, 06:33 PM
  3. JPA application noclassdeffound error
    By ishakteyran in forum New To Java
    Replies: 2
    Last Post: 03-12-2010, 07:31 PM
  4. JPA application noclassdeffound error
    By ishakteyran in forum Advanced Java
    Replies: 2
    Last Post: 03-11-2010, 01:14 AM
  5. JPA application noclassdeffound error
    By ishakteyran in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 03-11-2010, 12:34 AM

Posting Permissions

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