paperdoc-dev / paperdoc-lib
A zero-dependency PHP library for generating, parsing and converting documents (PDF, HTML, CSV, DOCX)
Fund package maintenance!
Requires
- php: ^8.2
- ext-dom: *
- ext-mbstring: *
- ext-zip: *
- ext-zlib: *
- neuron-core/neuron-ai: ^3.0
Requires (Dev)
- phpunit/phpunit: ^11.0
Suggests
- illuminate/support: ^11.0|^12.0 Required for Laravel integration (ServiceProvider, Facade)
README
A zero-dependency PHP library for generating, parsing and converting documents — PDF, HTML, CSV, DOCX, XLSX, PPTX, Markdown and more.
Features
- Generate documents from scratch (PDF, HTML, CSV, DOCX, XLSX, PPTX, Markdown)
- Parse existing documents into a unified in-memory model
- Convert between any supported formats in one call
- Batch processing — open and process multiple files at once
- Laravel integration — first-class ServiceProvider and Facade
- AI-powered features via Neuron AI (OCR, LLM extraction)
- Zero native binary dependencies — pure PHP
Requirements
| Dependency | Version |
|---|---|
| PHP | ^8.2 |
| ext-dom | * |
| ext-mbstring | * |
| ext-zip | * |
| ext-zlib | * |
Optional (Laravel)
| Package | Version |
|---|---|
| illuminate/support | ^11.0 | ^12.0 |
Installation
composer require paperdoc-dev/paperdoc-lib
Laravel auto-discovery
The PaperdocServiceProvider and Paperdoc facade are registered automatically via Laravel's package auto-discovery.
Quick Start
Standalone PHP
use Paperdoc\Support\DocumentManager; $manager = new DocumentManager(); // Create a PDF document $doc = $manager->create('pdf', 'My Report'); $doc->addSection() ->addParagraph('Hello, Paperdoc!') ->setBold(true); $manager->save($doc, 'output/report.pdf');
Laravel (via Facade)
use Paperdoc\Facades\Paperdoc; // Create $doc = Paperdoc::create('docx', 'Invoice #1042'); $doc->addSection()->addParagraph('Amount due: $500'); Paperdoc::save($doc, storage_path('invoices/1042.docx')); // Parse an existing file $doc = Paperdoc::open('uploads/report.xlsx'); // Convert directly Paperdoc::convert('report.docx', 'report.pdf', 'pdf'); // Render as string $html = Paperdoc::renderAs($doc, 'html'); // Batch open $docs = Paperdoc::openBatch([ 'file1.pdf', 'file2.docx', 'file3.xlsx', ]);
Supported Formats
| Format | Parse | Render/Generate |
|---|---|---|
| ✅ | ✅ | |
| HTML | ✅ | ✅ |
| DOCX | ✅ | ✅ |
| XLSX | ✅ | ✅ |
| PPTX | ✅ | ✅ |
| CSV | ✅ | ✅ |
| Markdown | ✅ | ✅ |
| DOC | ✅ | ✅ |
| XLS | ✅ | ✅ |
| PPT | ✅ | ✅ |
Document Model
Every format shares the same in-memory structure:
Document
└── Section[]
├── Paragraph (with TextRun[], bold, italic, font…)
├── Table → TableRow[] → TableCell[]
├── Image
└── PageBreak
Styles are encapsulated in Document/Style/ and can be applied at the paragraph, run, or section level.
Configuration
Publish the config (Laravel):
php artisan vendor:publish --tag=paperdoc-config
This creates config/paperdoc.php where you can set the default format, text styles, storage paths, and AI/OCR settings.
Testing
composer test # or ./vendor/bin/phpunit
Integration tests live in tests/Integration/, unit tests in tests/Unit/.
Architecture
src/
├── Concerns/ # Shared traits
├── Console/ # Artisan commands
├── Contracts/ # DocumentInterface, ParserInterface…
├── Document/ # Core model (Document, Section, Paragraph…)
├── Enum/ # Format enums
├── Facades/ # Laravel Facade
├── Factory/ # Document/Parser factories
├── Llm/ # AI/LLM integration (Neuron AI)
├── Ocr/ # OCR integration
├── Parsers/ # Format-specific parsers
├── Renderers/ # Format-specific renderers
├── Support/ # DocumentManager and helpers
└── PaperdocServiceProvider.php
Contributing
We welcome contributions! Please read CONTRIBUTING.md before opening a pull request.
Changelog
See CHANGELOG.md for release history.
License
Paperdoc Library is proprietary software. See the LICENSE file for details.
© 2024–2026 Paperdoc — paperdoc.dev