Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Filament Pdf Viewer Laravel Package

joaopaulolndev/filament-pdf-viewer

FilamentPHP PDF viewer for displaying documents in your admin UI. Adds a PdfViewerField for forms and an infolist entry to preview PDFs from database records or direct paths/URLs. Compatible with Laravel 11 and Filament 5.x.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:
    • FilamentPHP v5.3+ Integration: Aligns with the latest Filament ecosystem, ensuring compatibility with modern Laravel SaaS/enterprise applications. The PageConfiguration parameter support reflects Filament’s evolving architecture.
    • Seamless Eloquent Integration: Continues to leverage Laravel’s ORM for database-backed PDFs, reducing custom ORM logic.
    • Inline PDF Rendering: Supports browser-based viewers (PDF.js) and downloadable links, addressing UX and compliance needs.
    • MIT License: Retains ease of adoption for proprietary/commercial projects.
  • Cons:
    • FilamentPHP v5.3+ Dependency: Tight coupling with Filament’s latest version may limit reuse in older Filament apps or non-Filament Laravel projects.
    • No Native Advanced PDF Features: Still lacks support for annotations, forms, or redaction without extensions.
    • Client-Side Rendering Latency: PDF.js reliance may introduce performance issues for large/remote PDFs, though this is mitigated by Filament’s caching improvements in v5.3+.

Integration Feasibility

  • Medium Risk (Increased Due to Filament v5.3+):
    • FilamentPHP Compatibility: Now requires Filament v5.3+, which may introduce breaking changes if migrating from older versions (e.g., v3.x). Test thoroughly for:
      • PageConfiguration parameter usage in routes.
      • Any deprecated Filament APIs replaced in v5.3.
    • PDF Storage: Assumes Laravel’s Storage facade (filesystem/S3). Custom adapters may still require adjustments.
    • Authentication/Authorization: Inherits Filament’s policies; no built-in PDF-specific access control (e.g., row-level security).
  • Key Dependencies:
    • FilamentPHP v5.3+: Critical for compatibility. Verify all custom Filament logic aligns with v5.3’s changes.
    • PDF.js: Uses CDN by default (cdnjs.cloudflare.com). Self-hosting may be needed for offline use or compliance.

Technical Risk

  • Critical Risks:
    • Filament v5.3+ Migration: Risk of breaking changes if upgrading from older Filament versions. Mitigation:
    • Performance: Large PDFs (>10MB) may still degrade UI responsiveness. Leverage Filament v5.3’s improved caching or lazy-loading.
    • Security: PDF.js vulnerabilities remain a risk. Validate the package’s dependency updates (e.g., pdfjs-dist) for patches.
  • Medium Risks:
    • Caching: No built-in caching for PDF previews. Implement Cache::remember or use Filament v5.3’s Cache integration.
    • Offline Support: Relies on client-side PDF.js; no PWA/offline caching by default.

Key Questions for TPM

  1. Filament Version Alignment:
    • Are you already on Filament v5.3+? If not, what’s the upgrade path, and what resources are allocated for testing?
    • Do you have custom Filament logic (e.g., middleware, policies) that might conflict with v5.3 changes?
  2. Use Case Clarity:
    • Are PDFs user-generated (uploads) or static assets? This affects storage, access control, and scaling.
    • Will PDFs require metadata extraction (e.g., OCR) or interactive features (e.g., annotations)? This package doesn’t support these natively.
  3. Performance SLAs:
    • What’s the acceptable latency for PDF rendering? If >2s, consider server-side generation (e.g., barryvdh/laravel-dompdf) or Filament v5.3’s caching.
  4. Compliance:
    • Are there GDPR/retention policies for PDFs? The package lacks auto-deletion or audit logs.
  5. Alternatives:
    • Compare with Filament’s native file management or dedicated tools like spatie/laravel-medialibrary + custom PDF viewer.
  6. Long-Term Maintenance:
    • Is the package actively maintained? Confirm GitHub activity for issues/fixes post-v3.0.3.

Integration Approach

Stack Fit

  • Ideal For:
    • FilamentPHP v5.3+ admin panels (e.g., SaaS dashboards, internal tools).
    • Applications where PDFs are secondary assets (e.g., invoices, reports, user uploads).
    • Teams using Laravel’s ecosystem (Vite, Blade, Storage, etc.).
  • Less Ideal For:
    • Non-Filament v5.3+ Laravel apps (requires wrapper logic or Filament upgrade).
    • Projects needing advanced PDF manipulation (e.g., dynamic forms, digital signatures).

Migration Path

  1. Prerequisites:
    • Upgrade to FilamentPHP v5.3+:
      composer require filament/filament:"^5.3"
      
      Follow Filament’s upgrade guide for breaking changes.
    • Configure Laravel’s filesystem/S3 storage for PDFs (if not already done).
  2. Installation:
    composer require joaopaulolndev/filament-pdf-viewer:"^3.0"
    
    Publish config/assets if customization is needed:
    php artisan vendor:publish --tag="filament-pdf-viewer-config"
    
  3. Basic Setup:
    • For database-linked PDFs, attach the trait to a Filament resource:
      use JoaoPauloLN\FilamentPdfViewer\Concerns\HasPdfViewer;
      
      class InvoiceResource extends Resource {
          use HasPdfViewer;
      }
      
    • For standalone PDFs, use the PdfViewer widget in Filament forms/tables.
  4. Testing:
    • Validate PDF rendering in Filament v5.3+ (test PageConfiguration routes).
    • Test with different browsers (Chrome/Firefox/Safari).
    • Verify large files (>5MB) for performance.
    • Check access control (e.g., unauthorized users can’t view PDFs).

Compatibility

  • Laravel Versions: Tested with Laravel 10/11 (check composer.json constraints).
  • FilamentPHP: Requires v5.3+. Confirm no breaking changes in minor versions (e.g., v5.3.x).
  • PDF.js: Uses CDN by default (cdnjs.cloudflare.com). Self-host for offline use or compliance.
  • Storage: Works with Laravel’s Storage facade (local, S3, etc.). Custom adapters may need UrlGenerator overrides.

Sequencing

  1. Phase 1: Filament v5.3+ Upgrade (1–2 weeks):
    • Migrate Filament to v5.3+, resolving breaking changes.
    • Test core Filament features (e.g., resources, policies) in staging.
  2. Phase 2: Package Integration (2–3 days):
    • Install filament-pdf-viewer v3.0.3, configure basic PDF viewing for a single resource.
    • Test with 3–5 sample PDFs (varied sizes).
  3. Phase 3: Scaling & Customization (1–2 weeks):
    • Implement caching (e.g., Cache::remember or Filament v5.3’s Cache integration).
    • Customize PDF.js toolbar or add a loading spinner.
    • Set up row-level permissions for PDFs (via Filament’s policies).
  4. Phase 4: Monitoring & Optimization (Ongoing):
    • Log PDF rendering errors (e.g., corrupt files, 404s).
    • Monitor performance (e.g., Laravel Debugbar for PDF.js load times).
    • Plan for archival (e.g., cold storage for old PDFs).

Operational Impact

Maintenance

  • Proactive Tasks:
    • Dependency Updates:
      • Monitor joaopaulolndev/filament-pdf-viewer and pdfjs-dist for security patches.
      • Upgrade Filament to v5.3.x minor versions as they release.
    • Storage Cleanup: Implement a cron job to purge orphaned PDFs (if using database links).
    • Backup: Ensure PDF storage (filesystem/S3) is included in backup policies.
  • Reactive Tasks:
    • Filament v5.3+ Issues: Debug conflicts with custom Filament logic (e.g., PageConfiguration).
    • PDF Corruption: Handle unreadable PDFs via upload validation (e.g., file type checks).
    • Viewer Errors: Debug PDF.js errors (e.g., Unsupported PDF version) via browser console.

Support

  • User Issues:
    • **Common Pain Points
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
graham-campbell/flysystem
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi