Skip to content

Latest commit

 

History

History
125 lines (100 loc) · 2.78 KB

split-builder.md

File metadata and controls

125 lines (100 loc) · 2.78 KB

Split Builder

You may have the possibility to split several PDF pages or documents.

Basic usage

Warning

As assets files, by default the PDF files are fetch in the assets folder of your application.
For more information about path resolution go to assets documentation.

namespace App\Controller;

use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;

class YourController
{
    public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
    {
        return $gotenberg->split()
            ->files(
                'document_1.pdf',
                'document_2.pdf',
            )
            ->splitMode(SplitMode::Pages)
            ->splitSpan('1-2')
            ->splitUnify()
            ->generate()
            ->stream()
         ;
    }
}

Tip

For more information go to Gotenberg documentations.

splitMode

Warning

Required

Either intervals or pages.

namespace App\Controller;

use Sensiolabs\GotenbergBundle\Enum\SplitMode;
use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;

class YourController
{
    public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
    {
        return $gotenberg->split()
            ->files(
                'document_1.pdf',
                'document_2.pdf',
            )
            ->splitMode(SplitMode::Intervals)
            ->splitSpan('1')
            ->generate()
            ->stream()
         ;
    }
}

splitSpan

Warning

Required

Either the intervals or the page ranges to extract, depending on the selected splitMode.

namespace App\Controller;

use Sensiolabs\GotenbergBundle\Enumeration\SplitMode;
use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;

class YourController
{
    public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
    {
        return $gotenberg->split()
            ->files('document_1.pdf')
            ->splitMode(SplitMode::Intervals)
            ->splitSpan('1')
            ->generate()
            ->stream()
         ;
    }
}

splitUnify

Default: false

Specify whether to put extracted pages into a single file or as many files as there are page ranges. Only works with pages mode.

namespace App\Controller;

use Sensiolabs\GotenbergBundle\Enum\SplitMode;
use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;

class YourController
{
    public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
    {
        return $gotenberg->split()
            ->files('document_1.pdf')
            ->splitMode(SplitMode::Pages)
            ->splitSpan('1-2')
            ->splitUnify() // is same as ->splitUnify(true)
            ->generate()
            ->stream()
         ;
    }
}