I want to read the pdf file pagewise on JSP page so I have used com.itextpdf.text.pdf.PdfReader to read the content of the pdf file page by page. I used below code on JSP page :-
<%@ page language="java" import="java.io.*,java.util.*,java.lang.*, ,com.itextpdf.text.pdf.PdfReader,com.itextpdf.text.pdf.parser.PdfTextExtractor,
org.apache.commons.io.*,org.apache.http.entity.*"%><%!
%><%
try {
PdfReader reader = new PdfReader("D:\\text.pdf");
int n = reader.getNumberOfPages();
System.out.println("Number of Pages::::" + String.valueOf(n));
StringBuffer strBuf = new StringBuffer();
for (int i =1; i<=n;i++){
strBuf.append(PdfTextExtractor.getTextFromPage(reader, i));
strBuf.append(System.lineSeparator());
//Extracting the content from a particular page.
if(i<n){
strBuf.append(separator);
}
strBuf.append(System.lineSeparator());
}
System.out.println(strBuf.toString());
reader.close();
}
catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
%>
But when I run my application and call this JSP Page then I got exception[Unable to compile class for JSP].
Can anybody help me how do I resolve this issue to compile my JSP page properly?