Getting Started System requirements, installation and loading the SetaPDF-Signer component
Table of Contents
System Requirements and Installation
Because the SetaPDF-Signer component is based on the SetaPDF-Core component its system requirements and installation are almost identically.
Additionally the Signer component requires following PHP extensions to be enabled:
- OpenSSL
- Hash
- CURL (if you want to use signature timestamps or create LTV conforming signatures)
Loading the Component
The SetaPDF-Signer component makes use of classes and methods of the SetaPDF-Core component. The Signer component itself is integrated into the same structure and is fully covered by the autoload function of the Core component.
Loading the SetaPDF-Signer component is that simple:
require_once('/absolute/path/to/library/SetaPDF/Autoload.php');
or
require_once('../relative/path/to/library/SetaPDF/Autoload.php');
If the component is installed via Composer, just use the autoloader instance from Composer:
require 'vendor/autoload.php';
Error Handling
Beside the mentioned exception in the Core manual the Signer component has its own base exception: SetaPDF_Signer_Exception
.
Configuring the Temporary File Writer
The SetaPDF-Signer component must be able to save temporary files in the filesystem. This is done with the help of the SetaPDF_Core_Writer_TempFile
class. This class acts like a proxy around the SetaPDF_Core_Writer_File
class but will work on a temporary file that will be deleted in its __destruct()
method.
Temporary files are needed because most signature modules and/or their internal signature functions require the data that should to be signed is accessible through a local file path. Another reason and benefit is that this solution will allow you sign very large PDF files without hitting any memory limit.
The class uses the path returned by sys_get_temp_dir() as its default folder for temporary files (as of revision 809). If you want to configure this individually or if you want to control if the temporary files should be deleted automatically or not, following static methods are available:
getFilePrefix()
Get the file prefix for temporary files.
getKeepFile()
Get whether files should be kept or deleted automatically when an instance is destructed.
getTempDir()
Get the current temporary directory path.
setFilePrefix()
Set the file prefix for temporary files.
setKeepFile()
Set whether files should be kept or deleted automatically when an instance is destructed.
setTempDir()
Set the temporary directory path.