Skip to content

Fix(Demerge_pdfs): Fix crash on empty hardcoded PDF, PyPDF2 deprecations, add multi-mode splitting & CLI (#527) - #528

Open
Prayas340 wants to merge 1 commit into
ndleah:mainfrom
Prayas340:fix/demerge-pdfs-crash-and-improvements
Open

Fix(Demerge_pdfs): Fix crash on empty hardcoded PDF, PyPDF2 deprecations, add multi-mode splitting & CLI (#527)#528
Prayas340 wants to merge 1 commit into
ndleah:mainfrom
Prayas340:fix/demerge-pdfs-crash-and-improvements

Conversation

@Prayas340

Copy link
Copy Markdown

Description

This Pull Request refactors and modernizes the Demerge_pdfs project:

  • Fixes runtime crash caused by hardcoding the empty 0-byte Python.pdf file, adding interactive path prompts with validation as well as full command-line arguments.
  • Modernizes PDF handling with a unified PDFAdapter compatible with modern pypdf and PyPDF2 (v3+ and legacy versions).
  • Adds 4 splitting modes:
    1. Custom Interactive Wizard: Step-by-step assistant with remaining page counters and bounds validation.
    2. Equal Chunk Splitting: Splits PDF into parts of N pages each.
    3. Page Ranges Extraction: Extracts custom ranges (e.g. 1-5, 8, 12-20) or individual pages.
    4. Burst Mode: Splits every page into its own individual PDF document.
  • Adds CLI automation support with argparse flags (-i, -m, -p, -r, -o, --prefix).
  • Implements filename sanitization and safe context managers (with open(...)).
  • Adds automated test suite in test_demerging_pdfs.py (5/5 tests passing).
  • Adds requirements.txt and updates README.md with usage instructions and examples.

Fixes #527

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Documentation Update

Project

  • Your Project Name: Demerge_pdfs

  • Short Description: A robust, multi-mode Python utility to split, extract page ranges, or burst PDF documents using an interactive wizard or CLI automation.

Checklist:

  • I have named my files and folder, according to this project's guidelines.
  • My code follows the style guidelines of this project.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have created a helpful and easy to understand README.md, according to the given README_TEMPLATE.
  • My changes do not produce any warnings.
  • Added automated test suite test_demerging_pdfs.py.
  • Added requirements.txt.

…ons, add multi-mode splitting & CLI (ndleah#527)

- Resolve crash from hardcoded 0-byte Python.pdf by adding interactive path prompts and CLI arguments
- Modernize PDF library adapter with support for pypdf and PyPDF2 (v3.0+ and legacy)
- Implement 4 splitting modes: Interactive Wizard, Equal Chunk, Page Ranges, and Burst Mode
- Add full CLI argument parsing via argparse (-i, -m, -p, -r, -o, --prefix)
- Add safe file resource management and cross-platform filename sanitization
- Add automated test suite in test_demerging_pdfs.py
- Add requirements.txt and update README.md documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug & Feature(Demerge_pdfs): Fix crash on empty hardcoded PDF, PyPDF2 deprecations, and add multi-mode splitting & CLI

1 participant