Skip to content

A FPDI PDF Wrapper for Laravel which includes the "merge" functionality / Compatible S3

License

Notifications You must be signed in to change notification settings

gotDaijobu/laravel-pdfmerger-s3

 
 

Repository files navigation

Laravel PDFMerger with S3 Support

Software License

Credits

This package is a fork from NinpunTaruksha work to add S3 Compatibility on Webklex PdfMerger Package.

S3 compatibility is enhanced through the use of temp files instead of temp urls.

Install

Via Composer

$ composer require got-daijobu/laravel-pdfmerger-s3

Setup

Add the service provider to the providers array in config/app.php.

'providers' => [
    ...
    Webklex\PDFMerger\Providers\PDFMergerServiceProvider::class
],

'aliases' => [
    ...
    'PDFMerger' => Webklex\PDFMerger\Facades\PDFMergerFacade::class
]

Usage

A basic usage example:

use Webklex\PDFMerger\Facades\PDFMergerFacade as PDFMerger;

$oMerger = PDFMerger::init();

$oMerger->addPDF('/path/to/project/vendors/webklex/laravel-pdfmerger/src/PDFMerger/examples/pdf_one.pdf', [2]);
$oMerger->addPDF('/path/to/project/vendors/webklex/laravel-pdfmerger/src/PDFMerger/examples/pdf_two.pdf', 'all');

$oMerger->merge();
$oMerger->save('merged_result.pdf');

...add raw content data:

$oMerger->addString(file_get_contents('/path/to/project/vendors/webklex/laravel-pdfmerger/src/PDFMerger/examples/pdf_two.pdf'), [1]);

...add files from s3:

$oMerger->addPDFFromS3('/path/examples/pdf_two.pdf'), [1]);

...select the pages you want to merge:

$oMerger->addPDF($file, 'all');  //Add all pages
$oMerger->addPDF($file, [1]);    //Add page one only
$oMerger->addPDF($file, [2]);    //Add page two only
$oMerger->addPDF($file, [1, 3]); //Add page one and three only

...merge files together but add blank pages to support duplex printing:

$oMerger->duplexMerge();

...stream the merged content:

$oMerger->stream();

...download the merged content:

$oMerger->download();

..get the raw content data:

echo $oMerger->output();

...set the filename if you don't want to do it later:

$oMerger->setFileName('example.pdf');

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

A FPDI PDF Wrapper for Laravel which includes the "merge" functionality / Compatible S3

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%