async def extract_pdf_metadata(pdf_content: bytes) -> Metadata:
    """Extract metadata from a PDF document.

    Args:
        pdf_content: The bytes of the PDF document.

    Raises:
        ParsingError: If the PDF metadata could not be extracted.

    Returns:
        A dictionary of metadata extracted from the PDF.
    """
    try:
        document = parse(pdf_content, max_workers=1)
        metadata: Metadata = {}

        for raw_info in document.info:
            pdf_info = {k.lower(): v for k, v in asobj(raw_info).items()}
            _extract_basic_metadata(pdf_info, metadata)
            _extract_author_metadata(pdf_info, metadata)
            _extract_keyword_metadata(pdf_info, metadata)
            _extract_category_metadata(pdf_info, metadata)
            _extract_date_metadata(pdf_info, metadata)
            _extract_creator_metadata(pdf_info, metadata)

        if document.pages:
            _extract_document_dimensions(document, metadata)

        if document.outline and "description" not in metadata:
            metadata["description"] = _generate_outline_description(document)

        if "summary" not in metadata:
            metadata["summary"] = _generate_document_summary(document)

        _extract_structure_information(document, metadata)

        return metadata
    except Exception as e:
        raise ParsingError(f"Failed to extract PDF metadata: {e!s}") from e
Extract metadata from a PDF document.

    Args:
        pdf_content: The bytes of the PDF document.

    Raises:
        ParsingError: If the PDF metadata could not be extracted.

    Returns:
        A dictionary of metadata extracted from the PDF.
    
kreuzberg/_playa.py