/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.example.test; import java.io.File; import java.io.InputStream; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.text.PDFTextStripper; import org.apache.pdfbox.text.PDFTextStripperByArea; /** * * @author acer */ public class ReadPDFFile { public static void main(String[] args) { try { PDDocument document = null; document = PDDocument.load(new File("D:\\temp\\Signed_5755aa51-5501-461b-9ae5-98636266528d_test.pdf")); document.getClass(); if (!document.isEncrypted()) { PDFTextStripperByArea stripper = new PDFTextStripperByArea(); stripper.setSortByPosition(true); PDFTextStripper Tstripper = new PDFTextStripper(); String st = Tstripper.getText(document); System.out.println("Text:" + st); } } catch (Exception e) { e.printStackTrace(); } } }