konnco/pdf-merge

PHP PDF Merger

2.2.3 2021-09-10 04:19 UTC

This package is auto-updated.

Last update: 2024-11-10 11:12:04 UTC


README

PDF Merge library for PHP.

Forked from https://github.com/jurosh/php-pdf-merge

Install with composer:

composer require konnco/pdf-merge

Should add dependency:

"konnco/pdf-merge": "^2.0"

Highlights

Pdf merging with modes portrait/landscape or automatic mode.

Tested in Laravel 7 & Laravel 8 framework.

Usage

// Autoload composer classses...

// and now we can use library
$pdf = new \Konnco\PDFMerge\PDFMerger;

// add as many pdfs as you want
$pdf->addPDF('path/to/source/file.pdf', 'all', 'vertical')
  ->addPDF('path/to/source/file1.pdf', 'all', 'automatic')
  ->addPDF('path/to/source/file1.pdf', 'all')
  ->addPDF('path/to/source/file2.pdf', 'all', 'horizontal');

// call merge, output format `file`
$pdf->merge('file', 'path/to/export/dir/file.pdf');

That's it!

Enjoy and leave star if you like it :)