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

Browsershot Laravel Package

spatie/browsershot

Convert web pages or raw HTML to images and PDFs in PHP using Puppeteer-driven headless Chrome. Capture screenshots, generate PDFs, fetch rendered body HTML, and inspect triggered network requests—ideal for reports, previews, and testing.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Dynamic Document Generation: Enable advanced PDF/image generation with JavaScript execution in headless documents (e.g., modifying DOM after page load via evaluateOnNewDocument). Use cases expand to:
    • Post-render DOM manipulation: Inject dynamic data (e.g., timestamps, user-specific placeholders) into PDFs after initial render.
    • Complex form previews: Capture form states post-submission (e.g., "Thank You" pages with hidden data) for compliance or analytics.
    • A/B testing visual diffs: Generate side-by-side comparisons of JavaScript-rendered variants (e.g., layout changes).
  • Headless Testing & Debugging: Extend screenshot capabilities to verify post-load states (e.g., cookie banners, lazy-loaded content).
  • Build vs. Buy: Further reduces need for custom Puppeteer scripts by offering Laravel-native JavaScript execution in documents.
  • Roadmap:
    • Prioritize automated compliance tools (e.g., GDPR cookie banner validation via evaluateOnNewDocument).
    • Explore interactive PDFs (e.g., clickable forms in generated documents) using this feature.
    • Add visual regression testing for dynamic content (e.g., post-auth dashboard states).

When to Consider This Package

  • Adopt if:
    • Your app requires JavaScript execution during PDF/image generation (e.g., modifying DOM after page load).
    • You need to inject or validate data post-render (e.g., hidden fields, dynamic styles).
    • You’re building A/B testing tools, compliance validators, or interactive document generators.
  • Look elsewhere if:
    • You’re on a headless server without Node.js (use v2 with Chrome CLI or v1 with PhantomJS).
    • Your use case is static HTML (use dompdf or snappy).
    • You need high-volume batch processing (consider a dedicated microservice or queue workers).

How to Pitch It (Stakeholders)

Executives: *"This update lets us generate PDFs/images with real-time JavaScript execution—think of it as a ‘save as PDF’ button that can modify the page after it loads. For example:

  • Dynamic invoices: Add a ‘Paid’ stamp to PDFs only if the payment is confirmed.
  • Compliance tools: Automatically verify cookie banners appear in screenshots.
  • A/B testing: Compare how layout changes render in PDFs without manual checks. No frontend changes needed; we handle it all server-side."*

Engineering: *"New feature: evaluateOnNewDocument lets you run Puppeteer scripts after the page loads but before capturing the output. Key use cases:

  • Post-render DOM tweaks: Modify hidden fields, inject data, or validate UI states (e.g., ‘Error’ messages).
  • Laravel-native: Works seamlessly with existing Browsershot syntax:
    Browsershot::html($html)
        ->evaluateOnNewDocument('document.title = "Custom Title"')
        ->save('output.pdf');
    
  • Tradeoffs:
    • Requires Node.js/Puppeteer (containerizable).
    • Adds ~50ms overhead per request (benchmark for your workload). Perfect for: Compliance tools, dynamic previews, or any case where you need to ‘see’ the page after JavaScript runs."*
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai