Skip to content

This package is a wrapper for the TCPDF class that provides an elegant API for merging PDF files and returns a table of contents with bookmarks.

Notifications You must be signed in to change notification settings

aanders77/pdf-table-of-content

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

   

Pdf Merge & table of content Solution for PHP and Laravel

This package is a wrapper for the TCPDF class that provides an elegant API for merging PDF files and returns a table of contents with bookmarks.

This library is based on the source code of: karriereat/pdf-merge

The same code structure was used and the functionality was added to make a bookmark in each added document, later it returns an array with the document's table of contents in order to render it in a JS engine on the frontend side.

Installation

You can install the package via composer:

composer require gabrielchavezme/pdf-table-of-content

Usage

$pdfMerge = new PdfTableOfContent();

$pdfMerge->add([
    'file' => '/path/to/file1.pdf',
    'title' => 'File 1',
    'id' => 1
]);
$pdfMerge->add([
    'file' => '/path/to/file2.pdf',
    'title' => 'File 2',
    'id' => 2
]);

$pdfMerge->merge('/path/to/output.pdf');

Please note, that the merge method will throw an NoFilesDefinedException if no files where added.

Check for file existence

You can check if a file was already added for merging by calling:

$pdfMerge->contains('/path/to/file.pdf');

License

Apache License 2.0 Please see LICENSE for more information.

About

This package is a wrapper for the TCPDF class that provides an elegant API for merging PDF files and returns a table of contents with bookmarks.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%