virdiggg / merge-files
Merge words, excel, PDF and image into a single PDF
2.2.0
2025-02-24 06:19 UTC
Requires
- php: >=7.3.0
- mpdf/mpdf: ^8.0
- phpoffice/phpspreadsheet: ^1.19
- phpoffice/phpword: ^1.3
README
Not support image inside docx/doc
I don't plan to update this library in the meantime
mbstring
extension is needed
HOW TO USE
- Install this library with composer
composer require virdiggg/merge-files
- Install Ghostscript and make sure it can be called in command promp with
gs
. You will get something like this when you typegs
.
$ gs
$ GPL Ghostscript 10.04.0 (2024-09-18)
$ GS >
- Create function to call this library
<?php require_once __DIR__ . '/../vendor/autoload.php'; use Virdiggg\MergeFiles\Merge; try { $mf = new Merge(); $mf->setAuthor('Me'); $mf->setCreator('Also Me'); $mf->setOutputName('mergedpdf.pdf'); $mf->setOutputPath(__DIR__ . '/output/'); // $mf->setKeywords(['pdf', 'word', 'excel', 'image']); $mf->setTitle('Merged PDF'); // Mandatory $mf->setSubject('Merged PDF'); // Mandatory // $mf->setPassword('password'); // Mandatory if Permission is set // $mf->setPermissions(['copy']); // Optional, must be an array $files = [ __DIR__.'/input/new_pdf.pdf', __DIR__.'/input/Book1.xlsx', __DIR__.'/input/download.pdf', __DIR__.'/input/word.docx', __DIR__.'/input/Wikipedia-logo-v2.png' ]; $mf->mergeToPDF($files); } catch (Exception $e) { echo "Error: " . $e->getMessage(); }
Permission List
You can use any of the options listed below. Use []
(an empty array) if you do not want to set any permissions.
copy
print
modify
annot-forms
fill-forms
extract
assemble
print-highres