Get document info

Use get_document_info() or the static get_info() method to retrieve document metadata without performing a full conversion. This is useful for building file browsers, validation pipelines, and pre-conversion UIs.

Using static method

from groupdocs.markdown import MarkdownConverter

def get_info_static():
    """Retrieve document metadata using the static GetInfo method."""

    # Step 1: Get document info without performing a full conversion
    info = MarkdownConverter.get_info("business-plan.docx")

    # Step 2: Write the metadata fields to a text file
    with open("get-info-static.txt", "w", encoding="utf-8") as f:
        f.write(f"Format:    {info.file_format}\n")     # Docx
        f.write(f"Pages:     {info.page_count}\n")      # 42
        f.write(f"Title:     {info.title}\n")           # "Q3 Report"
        f.write(f"Author:    {info.author}\n")          # "Jane Doe"
        f.write(f"Encrypted: {info.is_encrypted}\n")    # False

if __name__ == "__main__":
    get_info_static()

business-plan.docx is sample file used in this example. Click here to download it.

Format:    Docx
Pages:     5
Title:     Meridian Outdoor Co. — Business Plan
Author:    Meridian Outdoor Co.
Encrypted: False

Download full output

Using instance method

from groupdocs.markdown import MarkdownConverter

def get_info_instance():
    """Retrieve document metadata using the instance API."""

    # Step 1: Open the spreadsheet with a context manager
    with MarkdownConverter("cost-analysis.xlsx") as converter:
        # Step 2: Retrieve document metadata
        info = converter.get_document_info()

        # Step 3: Write the metadata fields to a text file
        with open("get-info-instance.txt", "w", encoding="utf-8") as f:
            f.write(f"Format:    {info.file_format}\n")
            f.write(f"Pages:     {info.page_count}\n")
            f.write(f"Title:     {info.title}\n")
            f.write(f"Author:    {info.author}\n")
            f.write(f"Encrypted: {info.is_encrypted}\n")

if __name__ == "__main__":
    get_info_instance()

cost-analysis.xlsx is sample file used in this example. Click here to download it.

Format:    Xlsx
Pages:     4
Title:     
Author:    
Encrypted: False

Download full output

DocumentInfo properties

PropertyTypeDescription
file_formatFileFormatDetected file format (e.g., FileFormat.DOCX)
page_countintNumber of pages or worksheets
titlestrDocument title from metadata
authorstrDocument author from metadata
is_encryptedboolWhether the document is password-protected
Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.