Reading Your Own PDF File : PDF Read « PDF RTF « Java





Reading Your Own PDF File

import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfImportedPage;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfWriter;

public class ReadYourOwnPDFFile {
    public static void main(String[] args) {
        try {
            PdfReader reader = new PdfReader("YourOwnPDF.pdf");
            int n = reader.getNumberOfPages();
            // we retrieve the size of the first page
            Rectangle psize = reader.getPageSize(1);

            System.out.println(reader.getPdfVersion());
            System.out.println(reader.getFileLength());
            System.out.println(psize.height());
            System.out.println(psize.width());
        }
        catch (Exception de) {
            de.printStackTrace();
        }
    }
}

           
       










itext.zip( 1,748 k)

Related examples in the same category

1.Reads the pages of an existing PDF file and puts 2 pages from the existing doc into one of the new doc
2.Add Page Numbers to Existing PDF document