A document processing service based on Docling and Tesseract
1.9K
Document Processor is a FastAPI-based service that processes documents and extracts structured content as "slices". The API takes document files (primarily PDFs) as input and returns a structured representation of the document content, preserving the document hierarchy, positioning, and formatting.
GET /health
Returns information about the service status, including version, build ID, commit SHA, and uptime.
Response Example:
{
"version": "1.0.0",
"build_id": "20250401-1",
"commit_sha": "a1b2c3d4e5f6",
"up_since": "2025-04-01 08:00:00"
}
POST /process
Processes a document file and extracts its content as structured slices.
Request:
Response: Returns a list of document slices, each containing:
Response Example:
{
"slices": [
{
"level": 1,
"ref": "ref123",
"sequence": 0,
"parent_ref": "parent_ref",
"label": "Title",
"content": "Document Title",
"content_mime_type": "text/plain",
"positions": [
{
"page_no": 1,
"top": 100.0,
"right": 500.0,
"bottom": 120.0,
"left": 50.0,
"coord_origin": "TOPLEFT"
}
]
},
{
"level": 2,
"ref": "ref124",
"sequence": 1,
"parent_ref": "ref123",
"label": "Paragraph",
"content": "Content of the paragraph...",
"content_mime_type": "text/plain",
"positions": [
{
"page_no": 1,
"top": 150.0,
"right": 550.0,
"bottom": 200.0,
"left": 50.0,
"coord_origin": "TOPLEFT"
}
]
}
]
}
The API uses a document processing pipeline that includes:
Represents a piece of content extracted from the document:
level: Hierarchical level in the documentref: Reference IDsequence: Sequential order in the documentparent_ref: Reference to parent elementlabel: Content label/typecontent: Actual text contentcontent_mime_type: MIME type of the content (text/plain or text/markdown)positions: List of position informationRepresents the position of a slice on a document page:
page_no: Page numbertop, right, bottom, left: Bounding box coordinatescoord_origin: Coordinate origin (TOPLEFT or BOTTOMLEFT)You can run the API using Docker or directly with Uvicorn.
# Docker
docker run --rm -p 8000:8000 joanfabregat/document-processor:latest
# Development
uvicorn app.api:api --reload
# Production
uvicorn app.api:api --host 0.0.0.0 --port 8000
The Document Processor is licensed under the MIT License. See the LICENSE file for details.
Content type
Image
Digest
sha256:e9c5493a8…
Size
1.1 GB
Last updated
over 1 year ago
docker pull joanfabregat/document-processor