Download the PHP package iamgerwin/php-pdf-to-markdown-parser without Composer
On this page you can find all versions of the php package iamgerwin/php-pdf-to-markdown-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download iamgerwin/php-pdf-to-markdown-parser
More information about iamgerwin/php-pdf-to-markdown-parser
Files in iamgerwin/php-pdf-to-markdown-parser
Package php-pdf-to-markdown-parser
Short Description A lightweight PHP library to convert PDF documents into clean, structured Markdown. Supports text extraction, headings, lists, tables, diagrams and code blocks for easier content reuse and publishing.
License MIT
Homepage https://github.com/iamgerwin/php-pdf-to-markdown-parser
Informations about the package php-pdf-to-markdown-parser
PHP PDF to Markdown Parser
A lightweight PHP library to convert PDF documents into clean, structured Markdown. Supports text extraction, headings, lists, tables, diagrams and code blocks for easier content reuse and publishing.
Because sometimes PDFs just need to chill out and become Markdown.
Features
- 📝 Text Extraction with Styling - Preserves headings, bold, italic, and strikethrough formatting
- 📊 Table Parsing - Extracts tables with proper headers and body formatting
- 🎨 Diagram Support - Converts diagrams to Mermaid and dbdiagram.io formats
- Flowcharts
- Sequence diagrams
- Entity Relationship Diagrams (ERD)
- Gantt charts
- Class diagrams
- State diagrams
- Pie charts
- 📋 List Detection - Automatically converts bullet points and numbered lists
- 💻 Code Block Recognition - Identifies and formats code snippets
- 🚀 PHP 8.3 Compatible - Built with modern PHP features
- ✅ PSR-12 Compliant - Follows PHP coding standards
Installation
You can install the package via composer:
Usage
Basic Usage
Working with Tables
The parser automatically detects and converts tables in your PDF:
Diagram Extraction
Diagrams are automatically detected and converted to appropriate formats:
Mermaid Flowcharts: mermaid flowchart TD Start --> Process --> End
ERD (dbdiagram.io format): dbdiagram Table users { id int name varchar email varchar }
Sequence Diagrams: mermaid sequenceDiagram User->>System: Request System->>Database: Query Database->>System: Response System->>User: Result
Text Styling
The parser preserves text styling from PDFs:
- Headings (H1-H6) based on font size and formatting
- Bold text
- Italic text
Strikethrough text- Lists (bulleted and numbered)
- Code blocks
Advanced Configuration
Custom Extractors
You can extend the parser with custom extractors:
Testing
Run the test suite:
Run tests with coverage:
Run PHPStan static analysis:
Format code with Laravel Pint:
Requirements
- PHP 8.3 or higher
- ext-mbstring
How It Works
The parser uses a multi-stage extraction process:
- PDF Parsing - Uses the robust smalot/pdfparser library to extract raw content
- Text Analysis - Identifies text styling, headings, and formatting patterns
- Table Detection - Recognizes table structures (pipe, tab, or space-separated)
- Diagram Recognition - Detects diagram patterns and converts to Mermaid/dbdiagram formats
- Markdown Generation - Combines all elements into properly formatted Markdown
Limitations
- Images: Currently, images are not extracted (coming in future versions)
- Complex Layouts: Multi-column layouts may require manual adjustment
- Font Styling: Basic bold/italic detection is simplified (font metadata parsing is limited)
- Diagrams: Pattern matching may not catch all diagram types
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Acknowledgments
Built with inspiration from the PHP community and the need to make PDF content more accessible and reusable. Special thanks to the maintainers of smalot/pdfparser for their excellent PDF parsing library.