PDF

PDF Loader is a component designed for extracting information from PDF documents. PDF documents can vary significantly in terms of layout and structure.

This page provides a list of all supported PDF Loader in Document Processing Orchestrator (DPO).

Prerequisites

If you want to try the snippet code in this page:

Installation

# you can use a Conda environment
pip install --extra-index-url https://oauth2accesstoken:$(gcloud auth print-access-token)@glsdk.gdplabs.id/gen-ai-internal/simple/ "gllm-docproc[pdf]"

You can use the following as a sample file: pdf-example.pdf.

PyMuPDF Loader

PyMuPDFLoader is responsible to extract text and images in base64 format within PDF document. The text is extracted per paragraph, based on how the PyMuPDF library detects the paragraphs.

1

Create a script called main.py:

from gllm_docproc.loader.pdf import PyMuPDFLoader

source = "./data/source/pdf-example.pdf"

# initialize the PyMuPDF Loader
loader = PyMuPDFLoader()

# load source
loaded_elements = loader.load(source)
2

Run the script:

python main.py
3

The loader will generate the following: output JSON.

Last updated