CosExtractor

Overview

CosExtractor is a class in Aspose.PDF FOSS for Python.

Extract pages, streams, images and metadata from a PdfDocument.

This class provides 29 methods for working with CosExtractor objects in Python programs. Available methods include: __init__, as_bytes, attach_stream_decryption, detect_encryption, encryption_password_allows_access, extract_attachment_entries, extract_attachments, extract_decryption_key, extract_extgstates, extract_file_id, extract_fonts, extract_form_fields, and 16 additional methods. All public members are accessible to any Python application after installing the Aspose.PDF FOSS for Python package.

Methods

SignatureDescription
__init__(doc: PdfDocument, raw_data: bytes, stream_decrypt_key: bytes | None, stream_decrypt_algorithm: str, limits: PdfLoadLimits | None, budget: _LoadBudget | None)Calls init(doc, raw_data, stream_decrypt_key, stream_decrypt_algorithm, limits, budget) on this CosExtractor instance.
attach_stream_decryption(password: str)Configure per-stream decryption after the password is verified.
make_loader(s, r)Calls make_loader(s, r) on this CosExtractor instance.
extract_pages()list[tuple[float, float, float, float]]Calls extract_pages on this CosExtractor instance.
extract_page_contents()list[bytes]Calls extract_page_contents on this CosExtractor instance.
extract_pages_lazy(images_out: dict, page_image_map: dict, fonts_out: dict, extgstates_out: dict)list[tuple[float, float, float, float]]Return page MediaBoxes and discover resources without decoding streams.
get_page_content(page_index: int)bytesDecode and return the content stream for the page at page_index.
extract_fonts()dict[str, Any]Calls extract_fonts on this CosExtractor instance.
extract_extgstates()dict[str, Any]Calls extract_extgstates on this CosExtractor instance.
extract_images()dict[str, bytes]Returns a dictionary mapping image names to raw byte data, enabling developers to retrieve embedded images from a PDF
extract_images_per_page()dict[int, list[str]]Calls extract_images_per_page on this CosExtractor instance.
extract_image_sizes()dict[str, tuple[int, int]]Calls extract_image_sizes on this CosExtractor instance.
extract_image_meta()dict[str, dict[str, Any]]Return per-image reconstruction metadata gathered during traversal.
extract_image_placements() → `tuple[
    dict[tuple[int, str], tuple[float, ...]],

    dict[tuple[int, str], tuple[float, float, float, float]],

]` | Extract image placement matrix and rect from page content streams. |

| extract_metadata()dict[str, str] | Calls extract_metadata on this CosExtractor instance. | | standard_handler_encryption_algorithm()str | Return AES-256, AES-128, or RC4 for Standard security handler. | | extract_decryption_key(password: str)bytes \| None | Derive the file encryption key if password unlocks Standard encryption. | | as_bytes(obj: Any)bytes \| None | Calls as_bytes(obj) on this CosExtractor instance. | | encryption_password_allows_access(password: str)bool | True if password is correct, or verification is unavailable

    (minimal /Encrypt dict). |

| as_bytes(obj: Any)bytes \| None | Calls as_bytes(obj) on this CosExtractor instance. | | detect_encryption()bool | Calls detect_encryption on this CosExtractor instance. | | extract_file_id()list[bytes] \| None | Return the two-element /ID array from the trailer, or None. | | extract_permissions()int | Return the /P integer from the /Encrypt dictionary, or -4. | | extract_outlines()list[dict] | Return a list of outline-item dicts from the catalog /Outlines tree. | | extract_signature()dict[str, str] \| None | Calls extract_signature on this CosExtractor instance. | | extract_signatures(data: bytes)list[PdfSignature] | Calls extract_signatures(data) on this CosExtractor instance. | | extract_form_fields()dict[str, dict[str, Any]] | Extract all form fields with values and types. | | extract_attachment_entries()list[tuple[str, bytes, dict]] | Walk /Names /EmbeddedFiles, one entry per embedded file. | | extract_attachments()dict[str, bytes] | Return {name: bytes} for every embedded file. |

See Also