Reputation: 2372
I have some pdf need to extract to text only one pdf is truetype and it cause following error :
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.fontbox.ttf.TrueTypeFont.getAdvanceWidth(I)I
at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.getFontWidth(PDTrueTypeFont.java:677)
at org.apache.pdfbox.pdmodel.font.PDSimpleFont.getFontWidth(PDSimpleFont.java:231)
at org.apache.pdfbox.util.PDFStreamEngine.processEncodedText(PDFStreamEngine.java:411)
at org.apache.pdfbox.util.operator.ShowText.process(ShowText.java:45)
at org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngine.java:557)
at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:268)
at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngine.java:235)
at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine.java:215)
at org.apache.pdfbox.util.PDFTextStripper.processPage(PDFTextStripper.java:460)
at org.apache.pdfbox.util.PDFTextStripper.processPages(PDFTextStripper.java:385)
at org.apache.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:344)
at org.apache.pdfbox.util.PDFTextStripper.getText(PDFTextStripper.java:257)
I check the api source code and still can't get through it. Is there something I can do? or the 2.0 version solve this problem.
Upvotes: 3
Views: 2829
Reputation: 2372
It's not an big issue but some tiny mistake
Thanks to mkl and Tilman Hausherr
It's only buildpath problem.
First , I have muti versions of fontbox that I didn't aware of.
Just check it again and check it hard !
If others have same error, check the dependencies
pdfbox-1.x.x.jar
fontbox-1.x.x.jar
they need to be the same!
Upvotes: 8