gllm-docproc | Tutorial : PDF Loader | Use Case: Advanced DPO Pipeline | API Reference
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).
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 a Conda environment
$token = (gcloud auth print-access-token)
pip install --extra-index-url "https://oauth2accesstoken:$token@glsdk.gdplabs.id/gen-ai-internal/simple/" "gllm-docproc[pdf]"# you can use a Conda environment
FOR /F "tokens=*" %T IN ('gcloud auth print-access-token') DO SET TOKEN=%T
pip install --extra-index-url "https://oauth2accesstoken:%TOKEN%@glsdk.gdplabs.id/gen-ai-internal/simple/" "gllm-docproc[pdf]"You can use the following as a sample file: pdf-example.pdf.
Recommendation
For open-source version, we recommend to use combination of PyMuPDF and PDF Plumber. See Multi-Loader PDF Extraction.
For SaaS version, we recommend to use Azure AI Document Intelligence Loader.
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.
Create a script called main.py:
Run the script:
The loader will generate the following: output JSON.
PDF Plumber Loader
PDFPlumberLoader is responsible to extract tables from PDF documents. It identifies tables based on clear, well-defined borders. As a result, tables with missing or incomplete borders won't be detected.
Create a script called main.py:
Run the script:
The loader will generate the following: output JSON.
Multi-Loader PDF Extraction
In certain cases, we might need to combine multiple loader to enhance information extraction. Below is a sample implementation to load PDF document using PyMuPDFLoader and PDFPlumberLoader.
Create a script called main.py:
Run the script:
The loader will generate the following: output JSON.
Azure AI Document Intelligence Loader
AzureAIDocumentIntelligenceLoader extract text, tables, and images from PDF document using the Azure AI Document Intelligence, a cloud-based Azure AI service.
Create a script called main.py:
Run the script:
The loader will generate the following: output JSON.
Last updated