reading PDF files in java
807589Sep 11 2008 — edited Sep 12 2008Hi,
can any one help me on how to read pdf files in java using itext. I have written some piece of code but it is of no use. It is giving some garbage.
import java.io.*;
import java.util.*;
import java.lang.*;
import com.lowagie.text.pdf.PdfReader;
public class PdfAccess
{
public static void main(String[] args)
{
try {
String pdfFile = args[0];
PdfReader reader = new PdfReader(pdfFile);
int pageCount = reader.getNumberOfPages();
System.out.println(pageCount);
String content = " ";
for(int i=1;i<=pageCount;i++) {
byte[] pageContent = reader.getPageContent(i);
content = content+(pageContent.toString());
}
System.out.println(content.trim());
} catch(Exception e) { }
}
}
can any one help me on how to get contents of the file. Are there examples avalilable??