Add Files or Documents


The Merger component allows you to add PDF documents in 2 ways: It accepts a filename via the addFile() method or an existing document instance via the  addDocument() method. 

The addFile() and addDocument() Methods

Both methods are nearly identical in their method signature. The only difference is that the one accepts a path to a file and the other accepts an existing document instance


Add a document.


Add a document by filename.

So a simplest merge process could look like:


$merger = new \SetaPDF_Merger();
// add files from the file system

// initiate a document instance
$existingDocument = \SetaPDF_Core_Document::loadByString(
// and add this instance

// merge them together

// get the resulting document instance
$document = $merger->getDocument();
// add a writer
$document->setWriter(new \SetaPDF_Core_Writer_Http('simple.pdf', true));
// save and finish

Details about the other parameters are described on the following pages: