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

Pdf Bundle Laravel Package

bushidoio/pdf-bundle

View on GitHub
Deep Wiki
Context7

BushidoIOPDFBundle

The BushidoIOPDFBundle adds PDF file creation support in Symfony.

Features included:

  • PDF creation from HTML string content
  • Symfony\Component\HttpFoundation\Response object encapsulation with application/pdf content type
  • Temporal data and fonts paths can be located inside or outside Symfony app folder tree

Installation

Step 1: Composer

Add the following require line to the composer.json file:

{
    "require": {
        "bushidoio/pdf-bundle": "dev-master"
    }
}

And actually install it in your project using Composer:

php composer.phar install

You can also do this in one step with this command:

$ php composer.phar require bushidoio/pdf-bundle "dev-master"

Step 2: Enable the bundle

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new BushidoIO\PDFBundle\BushidoIOPDFBundle(),
    );
}

Configuration

Temporal content folders can be configured in app/config/config.yml. By default both tmp and ttffontdatapath folder will be stored in app/cache. Be sure you have write permissions on both folders.

bushidoio_pdf:
    tmp: ~
    ttffontdatapath: ~

Usage examples

You can transform any HTML string to PDF with the bushidoio_pdf service:

public function indexAction()
{
    ...
    $PDFService = $this->get('bushidoio_pdf');
    $html = '...';
    $pdf = $PDFService->createPDFFromHtml($html);
    ...
}

You can use Twig templates, or anything you like, to create the HTML string:

public function indexAction()
{
    ...
    $PDFService = $this->get('bushidoio_pdf');
    $html = $this->get('twig')->render(
        'default/index.html.twig',
        array(
            'greeting' => 'Hi'
        )
    );
    $pdf = $PDFService->createPDFFromHtml($html);
    ...
}

With the createResponse method a Symfony\Component\HttpFoundation\Response object is returned with application/pdf content type that will be directly downloaded if returned in a controller action:

public function indexAction()
{
    $PDFService = $this->get('bushidoio_pdf');
    $html = $this->get('twig')->render(
        'default/index.html.twig',
        array(
            'greeting' => 'Hi'
        )
    );
    
    return $PDFService->createResponse($html);
}
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.
headercat/phpstan-extension-ide-helper
yosymfony/parser-utils
innmind/black-box
babenkoivan/elastic-migrations
babenkoivan/elastic-adapter
sandermuller/package-boost-php
sandermuller/boost-core
depa/sulu-google-reviews-bundle
croct/plug-symfony
develia/commons
dmstr/symfony-system-resources-bundle
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
renatomarinho/laravel-page-speed
develia/geo-bundle
austinheap/laravel-database-encryption
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
imbo/imbo-coding-standard