pdf-organizer

Split, merge, and rename OCR-processed legal PDF documents by content.

636|91|Updated Jan 7, 2026
One-click install
npx skills add https://github.com/cat-xierluo/legal-skills --skill pdf-organizer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pdf-organizer
Source: https://github.com/cat-xierluo/legal-skills/tree/main/skills/pdf-organizer
Command: npx skills add https://github.com/cat-xierluo/legal-skills --skill pdf-organizer

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pypdf, ocrmypdf, and includes scripts (resource) and references (resource) components.

What problem does it solve?

Scanned legal case files often arrive as one large merged PDF or as arbitrarily split fragments with meaningless filenames, forcing lawyers to manually identify document boundaries and rename files. This Skill organizes OCR-processed PDFs into properly named individual legal documents based on their actual content.

Core Features & Use Cases

  • Content-Based Splitting and Merging: Detects document boundaries via titles, page-number resets, and signature blocks to split a combined scan into separate pleadings, contracts, and authorizations, or merges fragmented pages of the same document back together.
  • Standardized Legal Naming: Generates filenames following the pattern "document type + key parties + distinguishing suffix" (e.g., distinguishing standard vs. element-based civil complaints), with conservative "to be confirmed" placeholders for low-confidence results.
  • Reviewable Manifest Workflow: Produces page-level inspection indexes and draft manifests for AI or human review before execution, plus a handoff.json routing organized documents to downstream contract review, litigation analysis, or filing skills.
  • Use Case: A lawyer receives a 16-page scanned PDF containing a service contract, power of attorney, and two versions of a civil complaint; the Skill inspects each page, proposes a split manifest, and outputs four correctly named PDFs after review.

Quick Start

Ask the AI to inspect the scanned case PDF, generate an organize manifest draft, review the proposed document boundaries and filenames, then execute the split and rename into an output folder.

Frequently Asked Questions about pdf-organizer

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

FAQPage Schema
How do I split a scanned PDF into separate legal documents?

Run the script with --inspect to extract per-page titles, page numbers, and boundary signals, then generate a draft manifest with --suggest-manifest. After reviewing the manifest, execute it with pdf_organizer.py to split the PDF into individually named documents.

How to merge PDF fragments of the same legal document?

Define source_items in the organize manifest listing the fragment files in order, optionally with page ranges. The script merges them into one output PDF using pypdf and applies the suggested standardized filename.

Does PDF splitting work on scanned documents without OCR?

No. The script runs in strict text-layer mode by default and stops if no searchable text is detected. You must first process the scan with an OCR tool to create a dual-layer PDF before content-based splitting.

Can I rotate or deskew PDF pages during organization?

Yes. Set rotate to 90, 180, or 270 degrees per segment or globally in the manifest. Deskew is available when ocrmypdf is installed; otherwise complex image correction should be handled by a dedicated PDF processor.

What happens when document recognition confidence is low?

Low-confidence segments are marked needs_review with conservative filenames like "待确认 页码.pdf" rather than guessed names. The handoff.json flags review_required so downstream skills route these documents back for manual verification.