Skip to content

Merge word, excel, image, and PDF into a single PDF

License

Notifications You must be signed in to change notification settings

virdiggg/merge-files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Simple File Merging Library

Not support image inside docx/doc

I don't plan to update this library in the meantime

HOW TO USE

  • Install this library with composer
composer require virdiggg/merge-files
  • 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');

    $files = [
        __DIR__.'/input/Book1.xlsx',
        __DIR__.'/input/download.pdf',
        __DIR__.'/input/word.docx',
        __DIR__.'/input/img.jpg'
    ];
    $mf->mergeToPDF($files);
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}