Skip to content

mantamburini/p7m-extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues project_license

p7m-extractor

Scripts to extract original documents from .P7M signed files.

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Features
  3. Getting Started
  4. Usage
  5. Roadmap
  6. Contributing
  7. License
  8. Contact

About The Project

These scripts scan a specified directory for .P7M files (digitally signed containers) and extract the embedded PDF documents. They identify the PDF header within the P7M file and save the extracted content as a new PDF file.

Available implementations:

  • PowerShell (Extract-P7M.ps1) - Windows-native solution
  • Python (extract-p7m.py) - Cross-platform solution

(back to top)

Features

  • Extracts PDF files from P7M containers
  • Supports recursive directory scanning
  • Provides progress indication during processing
  • Offers detailed mode with tabular output
  • Validates input directory paths
  • Includes comprehensive error handling with colored output

(back to top)

Getting Started

Prerequisites

PowerShell Version

  • Windows PowerShell 5.1 or later
  • Execution policy allowing script execution (e.g., RemoteSigned)

Python Version

  • Python 3.6 or later
  • No additional dependencies required

Installation

  1. Clone the repo
    git clone https://github.com/mantamburini/p7m-extractor.git
    

(back to top)

Usage

PowerShell Script

.\Extract-P7M.ps1 [-Path <String>] [-Recurse] [-Detailed]

Parameters

  • -Path <String>
    The directory path to scan for .P7M files. Defaults to the current working directory. Must be a valid container path.

  • -Recurse <Switch>
    If specified, recursively scans subdirectories for .P7m files.

  • -Detailed <Switch>
    If specified, provides detailed processing information in tabular format instead of simple console messages.

Examples

  1. Extract PDFs from P7M files in the current directory:

    .\Extract-P7M.ps1
    
  2. Extract PDFs from a specific directory:

    .\Extract-P7M.ps1 -Path "C:\MyDocuments"
    
  3. Extract PDFs recursively from a directory:

    .\Extract-P7M.ps1 -Path "C:\MyDocuments" -Recurse
    
  4. Extract PDFs with detailed tabular output:

    .\Extract-P7M.ps1 -Path "C:\MyDocuments" -Detailed
    

Python Script

python extract-p7m.py [path] [-r] [-d]

Parameters

  • path (optional)
    The directory path to scan for .P7M files. Defaults to the current working directory.

  • -r, --recurse
    If specified, recursively scans subdirectories for .P7M files.

  • -d, --detailed
    If specified, provides detailed processing information in tabular format.

Examples

  1. Extract PDFs from P7M files in the current directory:

    python extract-p7m.py
    
  2. Extract PDFs from a specific directory:

    python extract-p7m.py "/path/to/documents"
    
  3. Extract PDFs recursively from a directory:

    python extract-p7m.py "/path/to/documents" -r
    
  4. Extract PDFs with detailed tabular output:

    python extract-p7m.py "/path/to/documents" -d
    

Output

PowerShell Version

  • Without -Detailed: Displays colored "OK " (green) for successful extractions, warnings for files without PDFs, or red error messages for processing failures.
  • With -Detailed: Outputs a table with columns: FileName, Status, OutputFile, Size. Exits early if no .p7m files are found.

Python Version

  • Without -d: Displays "OK " for successful extractions, "NO PDF " for files without PDFs, or error messages for processing failures.
  • With -d: Outputs a table with columns: FileName, Status, OutputFile, Size. Exits early if no .p7m files are found.

(back to top)

Roadmap

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the GPL-3.0 License. See LICENSE for more information.

(back to top)

Contact

Marcello Anselmi Tamburini

Project Link: https://github.com/mantamburini/p7m-extractor

(back to top)

About

PowerShell Script to extract original documents from .P7M signed files.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors