HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/pikepdf/__init__.py
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (C) 2017, James R. Barlow (https://github.com/jbarlow83/)

"""A library for manipulating PDFs

isort:skip_file
"""

import os

try:
    from . import _qpdf
except ImportError as _e:
    msg = "pikepdf's extension library failed to import"
    if os.name == 'nt':
        msg += (
            "\nYou may need to install Microsoft Visual C++ 2015-2019 "
            "Redistributable (x64) 14.24.28127 or newer."
        )
    raise ImportError(msg) from _e

try:
    from ._version import __version__
except ImportError as _e:
    raise ImportError("Failed to determine version") from _e

from ._qpdf import (
    ObjectStreamMode,
    Page,
    PasswordError,
    Pdf,
    PdfError,
    StreamDecodeLevel,
    Token,
    TokenFilter,
    TokenType,
)

from .objects import (
    Array,
    Dictionary,
    Name,
    Object,
    ObjectType,
    Operator,
    Stream,
    String,
)

from .models import (
    Encryption,
    PdfImage,
    PdfInlineImage,
    PdfMatrix,
    Permissions,
    UnsupportedImageTypeError,
    parse_content_stream,
    unparse_content_stream,
)

from . import _methods, codec

__libqpdf_version__ = _qpdf.qpdf_version()


def open(*args, **kwargs):  # pylint: disable=redefined-builtin
    """Alias for :func:`pikepdf.Pdf.open`. Open a PDF."""
    return Pdf.open(*args, **kwargs)


def new(*args, **kwargs):
    """Alias for :func:`pikepdf.Pdf.new`. Create a new empty PDF."""
    return Pdf.new(*args, **kwargs)