PHP code example of murkrow / pdf-utils

1. Go to this page and download the library: Download murkrow/pdf-utils library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

murkrow / pdf-utils example snippets


use Murkrow\PdfUtils\Services\ParsePdfTextService;
ParsePdfTextService::create()
        ->setInputFile("example.pdf")
        ->flattenText(false)
        ->execute()
        ->getOperationResult()

use Murkrow\PdfUtils\Services\MergePdfService;
MergePdfService::create()
        ->setInputFiles(["1.pdf", "2.pdf"])
        ->addInputFile("3.pdf")
        ->setOutputFile("123.pdf")
        ->execute();

use Murkrow\PdfUtils\Services\SplitPdfService;
SplitPdfService::create()
        ->setInputFile("123.pdf")
        ->setOutputFilesDirectory("splitting")
        ->fromPage(1)
        ->toPage(3)
        ->setOutputFileNamePrefix("output")
        ->execute();

use Murkrow\PdfUtils\Services\ExtractPdfPageRangeService;
ExtractPdfPageRangeService::create()
    ->fromPage(1)
    ->toPage(2)
    ->setInputFile('big.pdf')
    ->setOutputFile('subset.pdf')
    ->execute();
        

use Murkrow\PdfUtils\Services\GetPdfInfoService;
$result = GetPdfInfoService::create()
        ->setInputFile("123.pdf")
        ->execute();

dd($result->pages);
bash
php artisan vendor:publish --provider="Murkrow\PdfUtils\PdfUtilsServiceProvider"