PHP code example of peytwik / pdf-merger

1. Go to this page and download the library: Download peytwik/pdf-merger 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/ */

    

peytwik / pdf-merger example snippets


//nclude "vendor/autoload.php";

//initiate class
$merger = new \Peytwik\PDFMerger\PDFMerger;

//add directory where the files are located
$dir = $_SERVER['DOCUMENT_ROOT'] . "/";

//add the pdf files
$merger->AddFile($dir . 'pdf-sample.pdf');
$merger->AddFile($dir . 'sample.pdf');

//generate the file
$output = $merger->GenerateFile($dir . 'merged.pdf');