🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
⚠️ Malware / Trojaner / VirenWindows 11 just dropped the tool ransomware abused, Microsoft says don’t restore WMIC(10.09.2026 um 20:11 Uhr)
⚠️ Malware / Trojaner / VirenVorsicht: Android-Malware verschlüsselt Ihre Handys und nimmt heimlich Fotos auf(11.09.2026 um 09:35 Uhr)
🕵️ SicherheitslückenMicrosoft geht endlich eines der nervigsten Probleme von Windows 11 an(11.09.2026 um 11:58 Uhr)
💾 IT Security ToolsSysinternals Suite(11.09.2026 um 12:00 Uhr)
🕵️ SicherheitslückenDefender 0-Day ShieldBreak (CVE-2026-69414) nicht sauber gepatcht - BornCity(11.09.2026 um 12:52 Uhr)
🪟 Windows TippsThe Gemini desktop app is now available for Windows(11.09.2026 um 17:06 Uhr)
⚠️ Malware / Trojaner / VirenWindows 11 just dropped the tool ransomware abused, Microsoft says don’t restore WMIC(10.09.2026 um 20:11 Uhr)
⚠️ Malware / Trojaner / VirenVorsicht: Android-Malware verschlüsselt Ihre Handys und nimmt heimlich Fotos auf(11.09.2026 um 09:35 Uhr)
🕵️ SicherheitslückenMicrosoft geht endlich eines der nervigsten Probleme von Windows 11 an(11.09.2026 um 11:58 Uhr)
💾 IT Security ToolsSysinternals Suite(11.09.2026 um 12:00 Uhr)
🕵️ SicherheitslückenDefender 0-Day ShieldBreak (CVE-2026-69414) nicht sauber gepatcht - BornCity(11.09.2026 um 12:52 Uhr)

🔧 Programmierung 🕛 vor 5 Monaten 4 Min Lesezeit
0

I Built a Laravel Package for PDF Manipulation (Because Nothing Else Felt Right)

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

I was working on a client project where we needed to process uploaded PDFs before sending them to an AI model. The documents were multi-page city directory scans, and the AI worked best when fed individual pages rather than entire documents. Simple enough, I just needed to split PDFs.



So I started looking for a Laravel package. I found a few options, but nothing that felt right.






The Problem with PDF in the Laravel Ecosystem



The Laravel ecosystem offers excellent packages for generating PDFs, such as Spatie's laravel-pdf. However, when it comes to manipulating existing PDFs (e.g. splitting, merging, extracting pages or adding watermarks), the story is different.



Some of this can be done with existing tools. For example, FPDI can combine pages, and you can wrap CLI tools like qpdf or Ghostscript to split documents. But that leaves you writing all the integration code yourself. There's no filesystem disk support, no service container integration, and no fluent API.



I wanted something with a facade, chainable methods, and proper Storage integration. Something that feels like writing Eloquent queries, not fighting a CLI tool.






Meet Collate



under the hood. Here's what my original problem looks like with it:




CODE
use Johind\Collate\Facades\Collate;

$pages = Collate::open($request->file('directory-scan'))
->split('ai-processing/scan-page-{page}.pdf');

// $pages → Collection ['ai-processing/scan-page-1.pdf', ...]
// Now feed each page to your AI pipeline






That's it. The uploaded file is handled, pages are split, temp files are cleaned up automatically, and you get a collection of paths back.



But once I had the foundation in place, I kept going. I felt like this was missing in the ecosystem, and honestly it was just fun to build, so it grew into a full toolkit.






What Else Can You Do?



Merge multiple documents:




CODE
Collate::merge('cover.pdf', 'report.pdf', 'appendix.pdf')
->save('complete-report.pdf');






Watermark a document with an overlay:




CODE
Collate::open('proposal.pdf')
->overlay('branding/confidential-stamp.pdf')
->save('stamped-proposal.pdf');






Chain a whole workflow together. Add standard terms, set metadata, encrypt, and push to S3 in one go:




CODE
Collate::open($request->file('document'))
->addPages('legal/standard-terms.pdf')
->withMetadata(title: 'Client Report 2025')
->encrypt('client-password')
->toDisk('s3')
->save('reports/final.pdf');






Extract or remove specific pages:




CODE
Collate::open('document.pdf')
->onlyPages([1, 2, 3])
->save('first-three-pages.pdf');

Collate::open('document.pdf')
->removePages('5-10')
->save('trimmed.pdf');






Rotate pages, flatten forms, optimize for web:




CODE
Collate::open('scanned.pdf')
->rotate(90, range: '1-3')
->flatten()
->linearize()
->save('cleaned-up.pdf');






Read metadata and page counts without modifying anything:




CODE
$meta = Collate::inspect('document.pdf')->metadata();
$meta->title; // 'Quarterly Report'
$meta->author; // 'Taylor Otwell'

$count = Collate::inspect('document.pdf')->pageCount();






Everything chains.






Built for Laravel



A few things that make it feel native:



Storage disk integration. Read from S3, write to local, or the other way around. Collate handles the temp file dance for remote disks transparently:




CODE
Collate::fromDisk('s3')
->open('uploads/contract.pdf')
->toDisk('local')
->save('processed/contract.pdf');






It's Responsable. Return a PendingCollate directly from a controller and Laravel streams it to the browser. There's also download() and stream() if you need more control:




CODE
public function show()
{
return Collate::open('invoice.pdf');
}






Conditional operations via Laravel's Conditionable trait:




CODE
Collate::open('document.pdf')
->when($request->boolean('watermark'), fn ($pdf) => $pdf->overlay('watermark.pdf'))
->when($request->boolean('flatten'), fn ($pdf) => $pdf->flatten())
->save('output.pdf');






Macros for your own reusable operations:




CODE
PendingCollate::macro('stamp', function () {
return $this->overlay('assets/stamp.pdf');
});

Collate::open('contract.pdf')->stamp()->save('stamped.pdf');









Requirements



Collate requires PHP 8.4+, Laravel 11 or 12, and .





I'm actively working on the package, so feedback and issues are very welcome.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
The Gemini desktop app is now available for Windows
1 Quelle
Windows 11 just dropped the tool ransomware abused, Microsoft says don’t restore WMIC
1 Quelle
Vorsicht: Android-Malware verschlüsselt Ihre Handys und nimmt heimlich Fotos auf
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten I Built a Laravel Package for PDF Manipulation (Because Nothing Else Felt Right)

Thematisch verwandte Begriffe: Built, Laravel, Package, Manipulation · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...