PHP code example of fheider / pdfmerger

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

    

fheider / pdfmerger example snippets


use PDFMerger\Pdf;
$pdf = new Pdf();

$pdf->add('files/1.pdf');             // -- merge all pages
$pdf->add('files/2.pdf', [2]);        // -- merge only page 2
$pdf->add('files/3.pdf', [2-5]);      // -- merge page 2 to 5
$pdf->add('files/4.pdf', [1, 3-5]);   // -- merge page 1 and 3 to 5

$pdf->output('merged.pdf');         // -- send pdf to inline browser
$pdf->download('merged.pdf');       // -- force download
$pdf->save('merged.pdf');           // -- save merged pdf to new file