Extract PDF via Java

Parse text and images from PDF document. Use Aspose.PDF for Java to modify PDF files programmatically

Most popular action with Parser in Java

How to parse PDF with Java Library

Do you need to extract PDF? Programmatic modification of PDF documents is an essential part of modern digital workflows. With Java libraries like Aspose.PDF, developers can extract text from PDF or extract images from PDF. These libraries are stand-alone solutions that don’t rely on other software and are ready for commercial use. They cover all possible needs of professional Java developers.

  • Extract PDF data: texts, images, forms, fields, etc.
  • Extract text from PDF
  • Extract Images from PDF
  • Extract Fonts from PDF
  • Extract Data from the Form
  • Extract Text From Stamps
  • Extract Data from Table

In order to extract PDF file, we’ll use Aspose.PDF for Java API which is a feature-rich, powerful, and easy-to-use conversion API for the Java platform. You can download its latest version directly from Maven and install it within your Maven-based project by adding the following configurations to the pom.xml.


    <name>Aspose Java AP</name>


<version>version of aspose-pdf API</version>

Parse PDF via Java

You need Aspose.PDF for Java to try the code in your environment.

  1. Load the PDF with an instance of Document.
  2. Create TextAbsorber object to extract text.
  3. Accept the absorber for all the pages.
  4. Get the extracted text
  5. Create a writer and open the file, write a line of text to the file

Extract PDF Files - Java

This sample code shows how to extract PDF documents

Input file:

File not added

Output format:


Output file:

    // Open document
    com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(filePath);

    // Create TextAbsorber object to extract text
    com.aspose.pdf.TextAbsorber textAbsorber = new com.aspose.pdf.TextAbsorber();
    // Accept the absorber for all the pages
    // Get the extracted text
    String extractedText = textAbsorber.getText();                
    try {
        java.io.FileWriter writer = new java.io.FileWriter(_dataDir + "extracted-text.txt", true);
        // Write a line of text to the file
        // Close the stream
    } catch (java.io.IOException e) {

About Aspose.PDF for Java API

Aspose.PDF for Java API is a library that enables developers to add PDF processing capabilities to their applications. It can be used to build any type of 32-bit and 64-bit applications to generate or read, convert and manipulate PDF files without the use of Adobe Acrobat. Aspose.PDF for Java allows developers to insert tables, graphs, images, hyperlinks, custom fonts - and more - into PDF documents. Moreover, it is also possible to compress PDF. Aspose.PDF for Java provides excellent security features to develop secure PDF files.

You can find more information about Aspose.PDF for Java API on documentation and examples on how to use API. Some of the key features of Aspose.PDF for Java API include support for various file formats including HTML, XFA, TXT, PCL, XML, XPS and image file formats, support for various PDF versions, and extensive hyperlink functionality.