How to extract QR from PDF in Java with GroupDocs.Parser

In modern business workflows, extracting QR from PDF files can turn a manual data‑entry bottleneck into a fully automated pipeline. Whether you’re handling shipment manifests, retail receipts, or product catalogs, pulling QR information quickly and reliably is essential for downstream systems. This tutorial walks you through using GroupDocs.Parser for Java to read QR codes (and other barcodes) from PDFs and export the results to a clean XML file that your ERP, inventory, or analytics platform can consume.

Quick answers

  • What does GroupDocs.Parser for Java do? It reads PDF files and extracts structured data such as barcodes, tables, and text.
  • How to extract QR codes? Configure BarcodeOptions with the QR type and call parser.getBarcodes().
  • Can I read QR codes in Java? Yes—set the barcode type to "QR" in the options.
  • Do I need a license? A trial works for testing; a commercial license is required for production.
  • What Java version is required? Java 8 or higher is recommended.

What is “extract QR from PDF” in the context of PDF processing?

Extracting QR from PDF means scanning each page for QR‑encoded graphics, decoding the embedded data, and returning it in a program‑friendly format. GroupDocs.Parser abstracts the low‑level image analysis so you can focus on business logic rather than pixel manipulation.

Why use GroupDocs.Parser for QR extraction?

GroupDocs.Parser supports over 30 input formats and can process PDFs up to 500 MB without loading the entire file into memory, delivering high‑accuracy results even on low‑resolution scans. You can choose QualityMode.Low for speed or QualityMode.High for maximum precision, and the same API works for PDFs, images, and Office documents, eliminating the need for multiple libraries.

Prerequisites

  • GroupDocs.Parser for Java (version 25.5 or later).
  • Maven or manual JAR download.
  • Java 8+ development environment (IntelliJ IDEA, Eclipse, or any editor).

Setting up GroupDocs.Parser for Java

Using Maven

Add the GroupDocs repository and dependency to your pom.xml:

<repositories>
    <repository>
        <id>repository.groupdocs.com</id>
        <name>GroupDocs Repository</name>
        <url>https://releases.groupdocs.com/parser/java/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.groupdocs</groupId>
        <artifactId>groupdocs-parser</artifactId>
        <version>25.5</version>
    </dependency>
</dependencies>
<repositories>
    <repository>
        <id>repository.groupdocs.com</id>
        <name>GroupDocs Repository</name>
        <url>https://releases.groupdocs.com/parser/java/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.groupdocs</groupId>
        <artifactId>groupdocs-parser</artifactId>
        <version>25.5</version>
    </dependency>
</dependencies>

Direct download

Alternatively, download the latest JAR from GroupDocs.Parser for Java releases.

License acquisition steps

  • Free trial: 30‑day trial with full feature set.
  • Temporary license: Request a temporary key for extended evaluation.
  • Purchase: Obtain a commercial license for production deployments.

Basic initialization and setup

Create a Parser instance that points to the PDF you want to analyze:

Parser is the core class in GroupDocs.Parser that represents a document and provides methods for extracting content such as text, tables, and barcodes.

import com.groupdocs.parser.Parser;

class BarcodeExtractor {
    public static void main(String[] args) {
        // Initialize Parser object with the path to your PDF document.
        try (Parser parser = new Parser("YOUR_DOCUMENT_DIRECTORY")) {
            // Additional setup and usage will follow in the next sections.
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

How to read QR codes in Java PDFs using GroupDocs.Parser

Reading QR codes in Java PDFs with GroupDocs.Parser involves creating a parser instance, configuring barcode options to target QR types, invoking the barcode extraction method, and then handling the returned barcode objects. The process is straightforward, works on any PDF page, and returns the decoded values along with positional metadata for further processing.

Step 1: verify barcode support

Before attempting extraction, confirm that the document format supports barcode scanning:

if (!parser.getFeatures().isBarcodes()) {
    System.out.println("Document does not support barcode extraction.");
    return; // Exit if the document does not support barcode extraction
}

Explanation: This guard prevents runtime errors on unsupported file types.

Step 2: configure barcode options (read QR codes Java)

BarcodeOptions is a configuration object that lets you specify which barcode symbologies to detect, set the scanning quality mode, and fine‑tune parameters such as detection thresholds, ensuring optimal performance for the target QR codes.

import com.groupdocs.parser.options.BarcodeOptions;
import com.groupdocs.parser.options.QualityMode;

BarcodeOptions options = new BarcodeOptions(QualityMode.Low, QualityMode.Low, "QR");

Explanation: QualityMode.Low speeds up processing; switch to High if you need extra accuracy. The "QR" argument tells the engine to look for QR‑type barcodes only.

Step 3: extract the QR data

parser.getBarcodes(options) scans the document using the provided BarcodeOptions and returns a collection of PageBarcodeArea objects, each encapsulating the decoded QR value, the page number, and the exact coordinates of the barcode within the page, allowing precise downstream handling.

import com.groupdocs.parser.data.PageBarcodeArea;
import java.util.List;

Iterable<PageBarcodeArea> barcodes = parser.getBarcodes(options);

Explanation: parser.getBarcodes returns an iterable collection of PageBarcodeArea objects, each containing the decoded QR value and its location on the page.

Exporting extracted data to XML

Step 4: initialise the XML exporter

XmlExporter is a utility class that transforms a collection of barcode objects into a well‑structured XML document, automatically generating elements for each barcode with attributes for page index, position, and decoded value, which can then be saved or streamed to other systems.

import com.groupdocs.parser.export.XmlExporter;

XmlExporter exporter = new XmlExporter();

Explanation: The XmlExporter handles serialization of barcode objects into standard XML, ready for integration with ERP or inventory systems.

Step 5: write the XML file

Save the extracted QR information to disk:

exporter.exportBarcodes(barcodes, "YOUR_OUTPUT_DIRECTORY/data.xml");

Explanation: The resulting data.xml contains one <Barcode> element per QR code, with attributes for page number, coordinates, and decoded value.

Practical applications

  1. Inventory management: Auto‑populate stock databases by reading QR tags on incoming shipment PDFs.
  2. Supply‑chain visibility: Track packages in real time by extracting QR identifiers embedded in logistics documents.
  3. Retail receipts: Pull promotional or warranty information from QR codes printed on digital receipts.

Performance considerations

  • Memory management: For very large PDFs, process pages in a streaming fashion instead of loading the whole file into memory.
  • QualityMode selection: Use Low for bulk processing; switch to High when dealing with low‑resolution scans.
  • Library updates: Keep GroupDocs.Parser up‑to‑date to benefit from the latest performance improvements and bug fixes.

Common issues & troubleshooting

SymptomLikely causeFix
No barcodes returnedWrong barcode type specifiedChange "QR" to the appropriate type (e.g., "CODE_128").
Out‑of‑memory error on large PDFsWhole document loaded at onceProcess pages individually or increase JVM heap size (-Xmx2g).
Empty XML fileexportBarcodes called before extractionEnsure parser.getBarcodes(options) returns data before exporting.

Frequently asked questions

Q: Can I extract barcodes from image files using GroupDocs.Parser?
A: Yes, the library supports barcode extraction from common image formats (PNG, JPEG, TIFF).

Q: What barcode formats are recognized?
A: QR, Code 39, Code 128, DataMatrix, PDF417, and many more. Refer to the API docs for the full list.

Q: How should I handle password‑protected PDFs?
A: Pass the password to the Parser constructor: new Parser(filePath, "password").

Q: Is the trial version sufficient for production testing?
A: The trial provides full functionality but adds a watermark to extracted data. For production, acquire a commercial license.

Q: What if my PDF contains both QR and linear barcodes?
A: Create multiple BarcodeOptions instances or pass an array of types to scan for all needed formats in one pass.


Last Updated: 2026-10-12
Tested with: GroupDocs.Parser 25.5
Author: GroupDocs

Resources