The DocumentInformation Class

class PyPDF2.DocumentInformation[source]

Bases: PyPDF2.generic._data_structures.DictionaryObject

A class representing the basic document metadata provided in a PDF File. This class is accessible through PdfReader.metadata.

All text properties of the document metadata have two properties, eg. author and author_raw. The non-raw property will always return a TextStringObject, making it ideal for a case where the metadata is being displayed. The raw property can sometimes return a ByteStringObject, if PyPDF2 was unable to decode the string’s text encoding; this requires additional safety in the caller and therefore is not as commonly accessed.

property author: Optional[str]

Read-only property accessing the document’s author.

Returns a unicode string (TextStringObject) or None if the author is not specified.

property author_raw: Optional[str]

The “raw” version of author; can return a ByteStringObject.

property creation_date: Optional[datetime.datetime]

Read-only property accessing the document’s creation date.

property creation_date_raw: Optional[str]

The “raw” version of creation date; can return a ByteStringObject.

Typically in the format D:YYYYMMDDhhmmss[+-]hh’mm where the suffix is the offset from UTC.

property creator: Optional[str]

Read-only property accessing the document’s creator.

If the document was converted to PDF from another format, this is the name of the application (e.g. OpenOffice) that created the original document from which it was converted. Returns a unicode string (TextStringObject) or None if the creator is not specified.

property creator_raw: Optional[str]

The “raw” version of creator; can return a ByteStringObject.

getText(key: str) Optional[str][source]

The text value of the specified key or None.

Deprecated since version 1.28.0: Use the attributes (e.g. title / author).

property modification_date: Optional[datetime.datetime]

Read-only property accessing the document’s modification date.

The date and time the document was most recently modified.

property modification_date_raw: Optional[str]

The “raw” version of modification date; can return a ByteStringObject.

Typically in the format D:YYYYMMDDhhmmss[+-]hh’mm where the suffix is the offset from UTC.

property producer: Optional[str]

Read-only property accessing the document’s producer.

If the document was converted to PDF from another format, this is the name of the application (for example, OSX Quartz) that converted it to PDF. Returns a unicode string (TextStringObject) or None if the producer is not specified.

property producer_raw: Optional[str]

The “raw” version of producer; can return a ByteStringObject.

property subject: Optional[str]

Read-only property accessing the document’s subject.

Returns a unicode string (TextStringObject) or None if the subject is not specified.

property subject_raw: Optional[str]

The “raw” version of subject; can return a ByteStringObject.

property title: Optional[str]

Read-only property accessing the document’s title.

Returns a unicode string (TextStringObject) or None if the title is not specified.

property title_raw: Optional[str]

The “raw” version of title; can return a ByteStringObject.