import com.itextpdf.text.pdf.PdfReader;

public class Main {

    public static void main(String[] args) {
        PdfReader pdfReader = null;
        try {
            pdfReader = new PdfReader("test.pdf");
        } catch (Exception e){
            e.printStackTrace();
        }
        int pages = pdfReader.getNumberOfPages();
        for (int i=1; i<=pages; i++) {
            String pageContent = PdfTextExtractor.getTextFromPage(pdfReader, i);
            System.out.println("Content on Page " + i + ": " + pageContent);
        }
    }
}
