Weave 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

Chrome Pdf Bundle Laravel Package

daif/chrome-pdf-bundle

View on GitHub
Deep Wiki
Context7

UrlPdfBuilder

Generate a PDF from a URL.

Basic usage

From a URL

namespace App\Controller;

use Daif\ChromePdfBundle\ChromePdfInterface;

class YourController
{
    public function yourControllerMethod(ChromePdfInterface $chromePdf): Response
    {
        return $chromePdf->url()
            ->url('https://example.com')
            ->generate()
            ->stream()
         ;
    }
}

From a Symfony route

namespace App\Controller;

use Daif\ChromePdfBundle\ChromePdfInterface;

class YourController
{
    public function yourControllerMethod(ChromePdfInterface $chromePdf): Response
    {
        return $chromePdf->url()
            ->route('home', [
                'my_var' => 'value'
            ])
            ->generate()
            ->stream()
        ;
    }
}

Available methods

All methods from HtmlPdfBuilder are available, plus:

Method Description
url(string $url) URL of the page to convert
route(string $name, array $parameters) Symfony route to convert

Examples

PDF from external URL with cookies

$chromePdf->url()
    ->url('https://example.com/dashboard')
    ->cookies([
        ['name' => 'session', 'value' => 'abc123', 'domain' => 'example.com'],
    ])
    ->generate()
    ->stream()
;

PDF from internal route with custom headers

$chromePdf->url()
    ->route('report_page', ['id' => 42])
    ->extraHttpHeaders(['Authorization' => 'Bearer token'])
    ->paperStandardSize(PaperSize::A4)
    ->landscape()
    ->generate()
    ->stream()
;
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.
steadrun/laravel-monitor
labyrinthe/connect-laravel
elmogy/layan
drewdan/sentinel-client
dskripchenko/laravel-llm
fatryst/nuonuo
stevenay/myanfont
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin