Learning The "J"

Home » JAVA Learning » Working with PDF » Reading PDF » Reading PDF files

Reading PDF files

Reading PDF Files

import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.parser.PdfTextExtractor;
import java.io.FileWriter;
import java.io.IOException;

public class ReadingPDF {

    public static void main(String ar[]) {
        try {
            PdfReader readerN = new PdfReader("c:\\anchor.pdf");
            for (int i = 1; i <= 1; i++) {
                String myLine = PdfTextExtractor.getTextFromPage(readerN, i);
                System.out.println(myLine);

                try {
                    FileWriter fw = new FileWriter("c://reading.txt", true);
                    fw.write(myLine);
                    fw.close();
                } catch (IOException ioe) {
                    ioe.printStackTrace();
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Start here

%d bloggers like this: