1tomany/pdf-pack-bundle
Symfony bundle for 1tomany/pdf-pack that makes PDF metadata reading and page extraction easy via autowired actions. Supports Poppler tools (pdfinfo, pdftoppm, pdftotext) to rasterize pages to PNG or extract text with simple request objects.
Pros:
ExtractActionInterface, ReadActionInterface), enabling easy swapping of implementations (e.g., Poppler → Ghostscript → custom).ExtractRequest/ReadRequest and structured responses (ReadResponse, ExtractResponse), aligning with Laravel’s service container and DTO patterns.ExtractResponse) are iterable (Generator), enabling async processing or event dispatching (e.g., "page extracted")—useful for Laravel’s event system.Cons:
pdfinfo, pdftoppm, etc.), adding deployment complexity (e.g., Docker setup, CI/CD pipelines).ExtractActionInterface bindings) or via a custom ServiceProvider.config/ files or environment variables (e.g., .env for pdfinfo_binary paths).UploadFileHandler example).autoconfigure with Laravel’s bind() or extend() in a service provider.Mockery or Laravel\Pest).Event facade can listen to PDF extraction events (e.g., PageExtracted).imagick). Risk mitigation: Containerize dependencies (Docker) or use a Laravel-specific wrapper (e.g., spatie/pdf-to-image).pdftotext crashes) aren’t documented. Risk mitigation: Wrap actions in Laravel’s try-catch or use a retry mechanism (e.g., Laravel\Nova\Actions).when() or group() in phpunit.xml for test environments.Contract namespace vs. Laravel’s Illuminate\Contracts).Deployment Strategy:
Alternatives Evaluation:
spatie/pdf-to-image or barryvdh/laravel-dompdf for simpler use cases?Scaling:
Security:
storage_path() vs. temporary directories)Monitoring:
Log facade, Sentry)Laravel Compatibility:
AppServiceProvider:
public function register(): void
{
$this->app->bind(
OneToMany\PdfPack\Contract\Action\ExtractActionInterface::class,
OneToMany\PdfPack\Symfony\Extractor::class
);
// Repeat for ReadActionInterface
}
config/:
// config/onetomany_pdfpack.php
return [
'client' => env('PDFPACK_CLIENT', 'poppler'),
'poppler_client' => [
'pdfinfo_binary' => env('PDFINFO_BINARY', 'pdfinfo'),
// ...
],
];
.env for binary paths (e.g., PDFINFO_BINARY=/usr/bin/pdfinfo).HTTP Layer:
public function extractPdf(Request $request, ExtractActionInterface $extractAction)
{
$file = $request->file('pdf');
$response = $extractAction->act(new ExtractRequest($file->path()));
// Return images/text as JSON/stream
}
Phase 1: Proof of Concept (1–2 weeks)
UploadFileHandler example to a Laravel controller/service.mock config → Laravel’s config('onetomany_pdfpack.client' = 'mock')).Phase 2: Core Integration (2–3 weeks)
PdfPackServiceProvider to handle:
use OneToMany\PdfPack\Facades\PdfPack;
$metadata = PdfPack::read($filePath);
Phase 3: Production Readiness (1–2 weeks)
act() calls in try-catch).Log::debug('PDF extraction started')).FROM poppler/utils).imagick may compete with Poppler for system resources.ClientInterface for gs commands.PdfExtractor) using the bundle’s actions.PdfExtractionJob).1tomany/pdf-pack releases).1tomany/pdf-pack to a specific version in composer.json.package:discover to auto-load the bundle’s services.How can I help you explore Laravel packages today?