1

I am new to android. I have planned to develop a PDF viewer. I heard that there is a library available called iText to develop PDF viewer. Please tell me how to use the iText library with Android and how to develop the application using that library.

Brian Willis
  • 22,768
  • 9
  • 46
  • 50
Eshwar
  • 53
  • 1
  • 4
  • We can answer specific questions regarding how the library works, but we can't tell you how to write an entire application. If your needs change, feel free to ask another (much more specific) question. – Tim Post May 02 '11 at 04:57

1 Answers1

5

try this

public class ReadAndUsePdf {
    private static String INPUTFILE = "c:/temp/FirstPdf.pdf";
    private static String OUTPUTFILE = "c:/temp/ReadPdf.pdf";

    public static void main(String[] args) throws DocumentException,
            IOException {
        Document document = new Document();

        PdfWriter writer = PdfWriter.getInstance(document,
                new FileOutputStream(OUTPUTFILE));
        document.open();
        PdfReader reader = new PdfReader(INPUTFILE);
        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 == 2) {
                page = writer.getImportedPage(reader, i);
                Image instance = Image.getInstance(page);
                // here you can show image on your phone
            }
        }
        document.close();

    }

}
Nirmal- thInk beYond
  • 11,847
  • 8
  • 35
  • 46