NAME
Mail::SpamAssassin::PDF::Core - Core PDF parsing functions
DESCRIPTION
This module contains the core PDF parsing functions. It is not intended to be used directly, but rather to be used by other modules in this distribution.
METHODS
- new($fh)
-
Creates a new instance of the object. $fh is an open file handle to the PDF file or a reference to a scalar containing the contents of the PDF file.
- clone($fh)
-
Returns a new instance of the object with the same state as the original, but using the new file handle. This is useful for parsing objects within objects.
- pos($offset)
-
Sets the file pointer to the specified offset. If no offset is specified, returns the current offset.
- get_number
-
Reads a number from the file. A number can be an integer or a real number. Returns undef if no number is found.
- assert_number($num)
-
Get the next token from the file and croak if it isn't a number. If $num is specified, croak if the number doesn't match $num.
- assert_token($literal)
-
Get the next token from the file and croak if it doesn't match the specified literal.
- get_token
-
Get the next token from the file as a string of characters. Will skip leading spaces and comments. Returns undef if there are no more tokens. Will croak if an invalid character is encountered or if the token is too long.
- get_primitive
-
Reads a primitive object from the file. A primitive object can be a number, string, name, array, dictionary, or reference.
- get_line
-
Reads a line from the file. A line is a sequence of characters terminated by a line feed, a carriage return, or a carriage return/line feed combo. The returned string will include the newline character(s). The file pointer is left at the first character after the line.
- get_startxref
-
Reads the startxref value from the end of the file. Will croak if the startxref value is not found or is invalid.
- get_string
-
Reads a string from the file. A string is a sequence of characters enclosed in parentheses.
- get_hex_string
-
Reads a hex string from the file. A hex string is a sequence of hexadecimal digits enclosed in angle brackets with optional whitespace between the digits. If there is an odd number of hex digits, a zero is appended to the string. The string is then converted to binary and decrypted if necessary. If the string begins with a byte order mark (BOM), it is converted to UTF-8.
- get_array
-
Reads an array from the file. An array is a sequence of objects enclosed in square brackets.
- get_dict
-
Reads a dictionary from the file. A dictionary is a sequence of key/value pairs enclosed in double angle brackets.
- get_name
-
Reads a name from the file. A name is a sequence of characters beginning with a slash. A name can contain any character except whitespace and the characters ()<>[]{}/%. Any character except null (character code 0) may be included in a name by writing its 2-digit hexadecimal code, preceded by the number sign character (#)
- _get_array
-
Reads an array from the file. An array is a sequence of objects enclosed in square brackets. The file pointer is left at the first character after the array.