legal-ocr

Extract text from scanned Brazilian legal PDFs using PaddleOCR with EasyOCR fallback.

9|4|Updated Dec 11, 2025
One-click install
npx skills add https://github.com/fbmoulin/legal-ocr-skill --skill legal-ocr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: legal-ocr
Source: https://github.com/fbmoulin/legal-ocr-skill/tree/main/.
Command: npx skills add https://github.com/fbmoulin/legal-ocr-skill --skill legal-ocr

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill converts scanned Brazilian legal PDFs (sentenças, petições, acórdãos) into editable text with high accuracy, enabling quick digitization of archives, searchable databases, and automated workflows.

Core Features & Use Cases

  • High-precision OCR: Optimized for Portuguese legal language to maximize accuracy on court documents.
  • Multi-engine OCR: PaddleOCR as the primary engine, with EasyOCR as automatic fallback for difficult scans.
  • Advanced pre-processing: Deskew, noise removal, and CLAHE to improve readability before OCR.
  • Structure detection: Automatically identifies sections like relatório, fundamentação, dispositivo for structured outputs.
  • Quality validation: Confidence scoring and review flags to streamline human-in-the-loop checks.

Quick Start

Process a scanned PDF with the pipeline, for example: python pipeline_ocr.py sentenca.pdf

Frequently Asked Questions about legal-ocr

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I extract text from scanned legal PDFs?

Text extraction from scanned legal PDFs uses optical character recognition (OCR) to convert image-based documents into editable text. This Skill applies multi-engine OCR optimized for Portuguese legal language, preprocessing techniques like deskew and noise removal, and confidence scoring to produce high-accuracy output suitable for archival digitization and searchable databases.

Can I use OCR on Brazilian court documents with complex layouts?

Yes. This Skill handles multi-column layouts, tables, and variable image quality common in Brazilian legal documents—including historic archives. It automatically detects document structure (relatório, fundamentação, dispositivo sections), applies PaddleOCR with EasyOCR fallback, and flags low-confidence regions for human review.

What's the best way to prepare scanned PDFs for RAG and semantic search?

OCR-to-text conversion with structure detection and quality validation produces embeddings suitable for RAG pipelines. This Skill extracts text while identifying document sections and applying dictionary-based corrections tuned for Portuguese legal terminology, enabling downstream semantic search and jurisprudence indexing.

Do I need manual review after OCR processing?

Quality validation with confidence scoring and review flags enables human-in-the-loop checks, but is not required. Difficult scans automatically fall back to secondary OCR engines, and dictionary-based corrections improve accuracy on Portuguese legal language before output.

What file formats does legal PDF OCR support?

This Skill processes scanned PDFs (sentenças, petições, acórdãos) as input. Output formats support structured text extraction for use in searchable databases, RAG systems, and embeddings generation for semantic search applications.

Why would OCR fail on historic legal archives?

Historic archives often have poor image quality, fading, stains, and variable paper conditions. This Skill applies CLAHE contrast enhancement, noise removal, and deskewing before dual-engine OCR to handle these cases, with confidence scoring to identify remaining problem areas.