मुख्य सामग्री पर जाएँ

raygeo.formats.pdf.info

Reading PDF metadata, page boxes and optional-content layers.

Everything the reader reports about a document before its content is extracted: the page count, the size of the first page as it is displayed, the document title and the optional-content groups with their default on/off state. Documents that need a password are rejected.

PdfInfo​

Metadata of a PDF document.

encrypted​

encrypted: bool

Whether the document is encrypted.

height_pt​

height_pt: float

Height of the first page in PDF points, as displayed.

natural_size_mm​

natural_size_mm: tuple[float, float]

Width and height of the first page in millimetres.

page_count​

page_count: int

The number of pages in the document.

title​

title: Optional[str]

The document title from the info dictionary, if any.

width_pt​

width_pt: float

Width of the first page in PDF points, as displayed.

PdfLayer​

One optional-content group (PDF layer).

default_active​

default_active: bool

Whether the layer is on in the default configuration.

name​

name: str

The layer name stored in the OCG dictionary.

Functions​

is_pdf()​

is_pdf(data: bytes) -> bool

Return whether data starts with the PDF file marker.

ParameterTypeDescription
databytesThe first bytes of the file, or the whole file.
Returnsbool
ComplexityO(1)

read_info()​

read_info(data: bytes) -> formats.pdf.info.PdfInfo

Read the page count, first-page size and title of a PDF.

Raises: ValueError — When the document needs a password or is

damaged.
ParameterTypeDescription
databytesThe PDF file's bytes.
Returnsformats.pdf.info.PdfInfoThe document metadata. The page size is the one the page is displayed with.
ComplexityO(n) where n = size of the document

read_layers()​

read_layers(data: bytes) -> list[formats.pdf.info.PdfLayer]

List the optional-content groups (layers) of a PDF.

Raises: ValueError — When the document needs a password or is

damaged.
ParameterTypeDescription
databytesThe PDF file's bytes.
Returnslist[formats.pdf.info.PdfLayer]The layers in document order.
ComplexityO(n) where n = size of the document