This example explain about how to read PDF file using iText 5 PDF Library.
To read PDF file we need iText 5 jar. Download iText Jars from iText Website or Maven Repository
Page Count : 1
This example explain about how to create PDF file using iText 5 PDF Library. - Java Tutorial
Corner
To read PDF file we need iText 5 jar. Download iText Jars from iText Website or Maven Repository
Maven Dependency
ReadPDF.javacom.itextpdf itextpdf 5.5.11
package com.javatutorialcorner.itextpdf; import java.io.IOException; import com.itextpdf.text.pdf.PdfReader; import com.itextpdf.text.pdf.parser.PdfTextExtractor; public class ReadPDF { public static final String DEST = "C:/JTC/HelloWorld.pdf"; public static void main(String[] args) { PdfReader pdfReader; try { pdfReader = new PdfReader(DEST); int pageCount = pdfReader.getNumberOfPages(); System.out.println("Page Count : " + pageCount); // extract page 1 String textFromPDF = PdfTextExtractor.getTextFromPage(pdfReader, 1); System.out.println(textFromPDF); pdfReader.close(); } catch (IOException e) { e.printStackTrace(); } } }Output
Page Count : 1
This example explain about how to create PDF file using iText 5 PDF Library. - Java Tutorial
Corner
0 comments:
Post a Comment