getting exception: ClassNotFoundException
And I have included fontbox and pdfbox jar files in my classpath.
package com.KyaHub.action;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import org.apache.tika.exception.TikaException;
import org.apache.tika.metadata.Metadata;
import org.apache.tika.parser.ParseContext;
import org.apache.tika.parser.pdf.PDFParser;
import org.apache.tika.sax.BodyContentHandler;
import org.apache.fontbox.cmap.*;
import org.xml.sax.SAXException;
public class PdfParser {
private HttpServletRequest request;
public String execute() throws IOException,TikaException, SAXException {
BodyContentHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
FileInputStream inputstream = new FileInputStream(new File("C:/Users/admin/Downloads/cmp_column_width_example.pdf"));
ParseContext pcontext = new ParseContext();
try{
//parsing the document using PDF parser
PDFParser pdfparser = new PDFParser();
pdfparser.parse(inputstream, handler, metadata,pcontext);
//getting the content of the document
System.out.println("Contents of the PDF :" + handler.toString());
//getting metadata of the document
System.out.println("Metadata of the PDF:");
String[] metadataNames = metadata.names();
for(String name : metadataNames) {
System.out.println(name+ " : " + metadata.get(name));
}
}
catch(Exception e)
{
e.printStackTrace();
}
return "success";
}
//getter and setter
public HttpServletRequest getRequest() {
return request;
}
public void setRequest(HttpServletRequest request) {
this.request = request;
}
}
whenever i am changing the file name with APJ.AbdulKalamAzad.pdf i got output. But when I change the file name with another pdf file then I got the exception mentioned above.