pyhanko.pdf_utils.misc module

Utility functions for PDF library. Taken from PyPDF2 with modifications and additions, see here for the original license of the PyPDF2 project.

Generally, all of these constitute internal API, except for the exception classes.

exception pyhanko.pdf_utils.misc.PdfError

Bases: Exception

exception pyhanko.pdf_utils.misc.PdfReadError

Bases: pyhanko.pdf_utils.misc.PdfError

exception pyhanko.pdf_utils.misc.PdfWriteError

Bases: pyhanko.pdf_utils.misc.PdfError

exception pyhanko.pdf_utils.misc.PdfStreamError

Bases: pyhanko.pdf_utils.misc.PdfReadError

exception pyhanko.pdf_utils.misc.IndirectObjectExpected

Bases: pyhanko.pdf_utils.misc.PdfReadError

pyhanko.pdf_utils.misc.get_and_apply(dictionary: dict, key, function: Callable, *, default=None)
pyhanko.pdf_utils.misc.get_courier()
Returns

A resource dictionary representing the standard Courier font (or one of its metric equivalents).

class pyhanko.pdf_utils.misc.OrderedEnum(value)

Bases: enum.Enum

Ordered enum (from the Python documentation)

pyhanko.pdf_utils.misc.DEFAULT_CHUNK_SIZE = 4096

Default chunk size for stream I/O.

pyhanko.pdf_utils.misc.is_regular_character(byte_value: int)
pyhanko.pdf_utils.misc.read_non_whitespace(stream, seek_back=False, allow_eof=False)

Finds and reads the next non-whitespace character (ignores whitespace).

pyhanko.pdf_utils.misc.read_until_whitespace(stream, maxchars=None)

Reads non-whitespace characters and returns them. Stops upon encountering whitespace or when maxchars is reached.

pyhanko.pdf_utils.misc.read_until_regex(stream, regex, ignore_eof=False)

Reads until the regular expression pattern matched (ignore the match) Raise PdfStreamError on premature end-of-file. :param bool ignore_eof: If true, ignore end-of-line and return immediately :param regex: regex to match :param stream: stream to search

pyhanko.pdf_utils.misc.skip_over_comment(stream)
pyhanko.pdf_utils.misc.instance_test(cls)
pyhanko.pdf_utils.misc.peek(itr)