I want to read a pdf file using Java/Android from my SD card. I imported the itextpdf5.1.1.jar file in to Eclipse. I am able to read a file if I create a new file from an existing one, like this:
public void readPdfFile(String pFilename){
try{
Document document = null;
document = new Document();
PdfWriter writer = PdfWriter.getInstance(document,
new FileOutputStream(OUTPUTFILE));
document.open();
PdfReader reader = new PdfReader(pFilename);
int n = reader.getNumberOfPages();
PdfImportedPage page;
// Go through all pages
for (int i = 1; i <= n; i++) {
// Only page number 2 will be included
if (i == 1) {
page = writer.getImportedPage(reader, i);
Image instance = Image.getInstance(page);
document.add(instance);
}
}
}
catch (DocumentException e) {
// TODO: handle exception
System.out.println("Doc Exception"+ e);
}
catch (IOException io) {
// TODO: handle exception
System.out.println("IO Exception"+ io);
}
}
But I want to read the file without creating a new pdf file in my sd card. How can I do this?
Please guide me how to create a pdf reader application in Android that reads the pdf file and also allows you to enter a page number to jump to.