PDF

gllm-docprocarrow-up-right | Tutorial : PDF Loader | Use Case: Advanced DPO Pipeline | API Referencearrow-up-right

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).

chevron-rightPrerequisiteshashtag

This example specifically requires completion of all setup steps listed on the Prerequisites 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.pdfarrow-up-right.

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 JSONarrow-up-right.

PyMuPDF Span Loader

PyMuPDFLoader is responsible to extract text and images in base64 format within PDF document. The text is extracted per span—continuous character segments that share identical formatting.

1

Create a script called main.py:

2

Run the script:

3

The loader will generate the following: output JSONarrow-up-right.

Last updated