PHP code example of ninosimeon / pdf-merge

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

    

ninosimeon / pdf-merge example snippets


// Autoload classses...

// para invocar debes hacer lo siguiente
use NinoSimeon\PDFMerge\PDFMerger;
class xxx
{
	public function yyyy() {
		$pdf = new \NinoSimeon\PDFMerge\PDFMerger;
	}
}


// agrega todas las páginas que tu quieras
$pdf->addPDF('path/to/source/file.pdf', 'all', 'vertical')
  ->addPDF('path/to/source/file1.pdf', 'all')
  ->addPDF('path/to/source/file2.pdf', 'all', 'horizontal');

// al final puedes generar el archivo con este comando
$pdf->merge('file', 'path/to/export/dir/file.pdf');