Manuals

 

SetaPDF-Encryptor API - Constants / Configuration

The API needs some constants which are hard coded into the API or have to be defined by you. There is also a constant that requires definition prior to first use.

Also you can define global variables which affects the behaviour of specific tasks.

Global Configuration Variables

$GLOBALS['SETAPDF_PARSE_INVALID_FILES'] (boolean)

(DEPRECATED) If this global variable is set the pdf parser tries to read/repair invalid PDF documents. This setting could affect the processtime on huge files very much.

This variable isn't used by the parser as of version 1.3 (all current version of the SetaPDF APIs)

$GLOBALS['SETAPDF_SEARCH_FOR_XREF_OFFSET'] (integer)

With this global variable you can adjust the offset position from which the pdf parser should search for the pointer to the xref table. If not defined the default value of 1500 is used.

The pdf specification says it has to be in the last 1024 bytes of a file. But sometimes there are errorious document in the wild that have some garbage at the end so we need the possibility to do a kind of finetuning for them.

Predefined Version Constants

The following constants defines the versions of specific files of the SetaPDF core:

SETAPDF_CORE_VERSION (string) = 1.3

Version of the abstract SetaPDF class. Defined in /SetaPDF/SetaPDF.php

SETAPDF_PARSER_VERSION (string) = 1.3

Version of the SetaPDF_Parser class. Defined in /SetaPDF/SetaPDF_parser.php

SETAPDF_PDF_CONTEXT_VERSION (string) = 1.3

Version of the pdf_context class. Defined in /SetaPDF/pdf_context.php

SETAPDF_WRAPPER_FUNCTIONS_VERSION (string) = 1.2.1

Version of the wrapper functions file. Defined in /SetaPDF/wrapper_functions.php

Constants to define

SetaPDF_ENCRYPTOR_CACHEPATH (string)

The constant SetaPDF_ENCRYPTOR_CACHEPATH has to contain a path to which the PHP process can write and read. This constant must be set as soon as the caching system is activated. Otherwise the caching system will not be used.

As of version 1.5 a new global caching function exists and the API own functionality will be removed in coming version.

Predefined Constants

SETAPDF_ENC_RC4_40 (integer) = 0

Standard encryption with 40-bits.

SETAPDF_ENC_RC4_128 (integer) = 1

Standard encryption with 128-bits.

SETAPDF_ENC_AES_128 (integer) = 2

AES (Advanced Encryption Standard) encryption with 128-bits.

SETAPDF_ENC_AES_256 (integer) = 3

AES (Advanced Encryption Standard) encryption with 256-bits.

Predefined Constants for Errorhandling

Possible errorcodes for the SetaPDF main class starts at 1 and ends at 99.

E_SETAPDF_CANNOT_OPEN_FILE (integer) = 1

cannot open XXXX !

E_SETAPDF_UNABLE_TO_POINT_TO_XREF_TABLE (integer) = 2

Unable to find pointer to xref table

E_SETAPDF_UNABLE_TO_FIND_XREF (integer) = 3

Unable to find xref table - Maybe a Problem with 'auto_detect_line_endings'

E_SETAPDF_UNEXPECTED_HEADER_IN_XREF_TABLE (integer) = 4

Unexpected header in xref table

E_SETAPDF_UNEXPECTED_DATA_IN_XREF_TABLE (integer) = 5

Unexpected data in xref table

E_SETAPDF_FILE_IS_ENCRYPTED (integer) = 6

File is encrypted!

E_SETAPDF_WRONG_TYPE (integer) = 7

Wrong Type of Element

E_SETAPDF_UNABLE_TO_FIND_OBJECT (integer) = 8

Unable to find object at expected location

E_SETAPDF_ENC_UNSUPPORTED_FILTER (integer) = 9
E_SETAPDF_ENC_UNSUPPORTED_ALGO (integer) = 10
E_SETAPDF_ENC_UNSUPPORTED_REVISION (integer) = 11
E_SETAPDF_ENC_NO_RIGHTS_FOR_SPECIFIC_ACTION (integer) = 12
E_SETAPDF_ENC_WRONG_OWNER_PW (integer) = 13
E_SETAPDF_CANNOT_COPY_FILE (integer) = 14

Cannot copy file XXXX to YYYY

E_SETAPDF_HEADER_ALREADY_SEND (integer) = 15

Some data has already been output to browser, can't send PDF file

E_SETAPDF_UNABLE_TO_FIND_TRAILER (integer) = 16

Trailer keyword not found after xref table

E_SETAPDF_UNSUPPORTED_FILTER (integer) = 17

An unsupported compression filter is required.

E_SETAPDF_ZLIB_REQUIRED (integer) = 18

To handle /FlateDecode filter, php with zlib support is needed.

E_SETAPDF_DECOMPRESSION_ERROR (integer) = 19

Error while decompressing stream.

E_SETAPDF_UNABLE_TO_CREATE_CACHE_DIR (integer) = 20

Unable to create directories in cache directory.

API Related Predefined Constants for Errorhandling

Possible errorcodes for the SetaPDF-Encryptor API starts at 300 and ends at 399.

E_SETAPDF_ENC_ERR_PERM (integer) = 300

Error description: Incorrect permission

E_SETAPDF_ENC_ERR_PERM_40BIT (integer) = 301

Error description: Incorrect permission for 40bit

E_SETAPDF_ENC_ERR_CACHEUPDATE_NOT_POSSIBLE (integer) = 302

Error description: A Cache Update is only possible when $this->usecache is true.

E_SETAPDF_ENC_ERR_MCRYPT_NOT_AVAILABLE (integer) = 303

AES encryption requires mcrypt to be installed.

E_SETAPDF_ENC_ERR_MCRYPT_RIJNDAEL_128_NOT_AVAILABLE (integer) = 304

Needed cipher (RIJNDAEL_128) not available.

E_SETAPDF_ENC_TMPDIR_DOES_NOT_EXISTS (integer) = 306

Fallback temporary directory _tmp/ does not exists.

E_SETAPDF_ENC_DIR_DOES_NOT_EXISTS (integer) = 307

Directory "%s" does not exists.

E_SETAPDF_ENC_OPENSSL_ERROR (integer) = 308

An OpenSSL error occurs + all results from openssl_error_string()

E_SETAPDF_ENC_OPENSSL_BOUNDARY_ID_NOT_FOUND (integer) = 309

Cannot find boundary id in smime message.

E_SETAPDF_ENC_OPENSSL_ENC_EXTRACTION (integer) = 310

Error while extracting the encrypted content of the smime message.

E_SETAPDF_ENC_PKSEC_NOT_POSSIBLE (integer) = 311

Public-Key Security is not supported for RC4 40bit encryption.

E_SETAPDF_ENC_OPENSSL_NOT_AVAILABLE (integer) = 312

This module requires php compiled with openssl.

Constans for Cache Mechanism

The following constants are used to control the behaviour of the caching mechanism of the pdf parser.

SETAPDF_P_CACHE_NO (integer) = 0x00

Don't read and write cache.

SETAPDF_P_CACHE_READ_XREF (integer) = 0x01

Try to read the cached xref table.

SETAPDF_P_CACHE_WRITE_XREF (integer) = 0x02

Write the xref table to cache.

SETAPDF_P_CACHE_XREF (integer) = 0x01 | 0x02

Try to read and write the xref table.

SETAPDF_P_CACHE_READ_OBJECTS (integer) = 0x04

Try to read cached objects.

SETAPDF_P_CACHE_WRITE_OBJECTS (integer) = 0x08

Write read objects to cache.

SETAPDF_P_CACHE_OBJECTS (integer) = 0x04 | 0x08

Try to read and write objects to cache.

SETAPDF_P_CACHE_ALL (integer) = 0x01 | 0x02 | 0x04 | 0x08

Read and write objects and xref-tables.