pyhanko.pdf_utils.extensions module
- class pyhanko.pdf_utils.extensions.DevExtensionMultivalued(value)
Bases:
Enum
Setting indicating how an extension is expected to behave well w.r.t. the new mechanism for multivalued extensions in ISO 32000-2:2020.
- ALWAYS = 1
Always serialise this extension as a multivalued extension.
- NEVER = 2
Never serialise this extension as a multivalued extension.
- MAYBE = 3
Make this extension single-valued whenever possible, but allow multiple values as well, e.g. when a different but non-comparable extension with the same prefix is already present in the file.
- class pyhanko.pdf_utils.extensions.DeveloperExtension(prefix_name: NameObject, base_version: NameObject, extension_level: int, url: Optional[str] = None, extension_revision: Optional[str] = None, compare_by_level: bool = False, subsumed_by: Iterable[int] = (), subsumes: Iterable[int] = (), multivalued: DevExtensionMultivalued = DevExtensionMultivalued.MAYBE)
Bases:
object
PDF developer extension designation.
- prefix_name: NameObject
Registered developer prefix.
- base_version: NameObject
Base version on to which the extension applies.
- extension_level: int
Extension level.
- url: Optional[str] = None
Optional URL linking to the extension’s documentation.
- extension_revision: Optional[str] = None
Optional extra revision information. Not comparable.
- compare_by_level: bool = False
Compare developer extensions by level number. If this value is
True
and a copy of this extension already exists in the target file with a higher level number, do not override it. If one exists with a lower level number, override it.If this value is
False
, the decision is based onsubsumed_by
andsubsumes
.Warning
It is generally not safe to assume that extension levels are used as a versioning system (i.e. that higher extension levels supersede lower ones), hence why the default is
False
.
- subsumed_by: Iterable[int] = ()
List of extension levels that would subsume this one. If one of these is present in the extensions dictionary, attempting to register this extension will not override it.
Default value: empty.
Warning
This parameter is ignored if
compare_by_level
isTrue
.
- subsumes: Iterable[int] = ()
List of extensions explicitly subsumed by this one. If one of these is present in the extensions dictionary, attempting to register this extension will override it.
Default value: empty.
Warning
This parameter is ignored if
compare_by_level
isTrue
.
- multivalued: DevExtensionMultivalued = 3
Setting indicating whether this extension is expected to behave well w.r.t. the new mechanism for multivalued extensions in ISO 32000-2:2020.
- as_pdf_object() DictionaryObject
Format the data in this object into a PDF dictionary for registration into the /Extensions dictionary.
- Returns