Add Files or Documents
Introduction
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.
Description
public SetaPDF_Merger::addDocument (
SetaPDF_Core_Document|array $documentOrConfig [,
mixed $pages = null [,
string|array $nameConfig = null [,
null|string|array $outlinesConfig = null [,
boolean $copyLayers = true ]]]]
):
int|null Add a document.
Same as addFile()
but the document has to be passed as
SetaPDF_Core_Document
instance.
Parameters
- $documentOrConfig : SetaPDF_Core_Document|array
The document or config array. If an array is passed the keys
has to be named as the method parameters. All other
parameters are optional then.
- $pages : mixed
The pages to add from the file. See
_checkPageNumber()
for a full description.
- $nameConfig : string|array
The configuration for a named destination for this file.
- $outlinesConfig : null|string|array
The outlines config
- $copyLayers : boolean
Whether to copy layer information of the document
Exceptions
Throws InvalidArgumentException
See
Add a document by filename.
Description
public SetaPDF_Merger::addFile (
string|array $filenameOrConfig [, mixed $pages = null [, string|array $nameConfig = null [, null|string|array $outlinesConfig = null [, boolean $copyLayers = true ]]]]
):
int|null Add a document by filename.
The document could include dynamic content like form fields, links or any other page annotation.
Form fields are handled especially:
If a document was added with form fields which names were already used by a previously added
document the field name will be suffixed with a slash and a number.
This behavior may lead to corrupted java scripts which may calculate field sums by field names!
Parameters
- $filenameOrConfig : string|array
The filename or config array. If an array is passed the keys has to be
named as the method parameters. All other parameters are optional then.
- $pages : mixed
The pages to add from the file. See
_checkPageNumber()
for a full
description.
- $nameConfig : string|array
The configuration for a named destination for this file.
- $outlinesConfig : null|string|array
The outlines config,
- $copyLayers : boolean
Whether to copy layer information of the document.
Exceptions
Throws InvalidArgumentException
So a simplest merge process could look like:
Details about the other parameters are described on the following pages: