KeyView 24.3

# Obtain Format Information

The KeyView format detection module (`kwad`) detects a file's format, and reports the information to your application.

You can obtain format information through the `info` attribute of a `document` object.

Copy

    import keyview.filter as kv
    import argparse

    # Add your KeyView license here
    KEYVIEW_LICENSE = "..."

    parser = argparse.ArgumentParser(description = "IDOL KeyView Python API - file format detection")
    parser.add_argument("file_path", help="The path of the input file")
    parser.add_argument("--bin-path", help="The path to the KeyView bin directory", default='.')
    args = parser.parse_args()

    try:
        # Create a new KeyView session
        with kv.FilterSession(args.bin_path, KEYVIEW_LICENSE) as session:

            # Open a document
            with session.open(args.file_path) as doc:

                # Print information about the document
                print(f"Format Name:  \t {doc.info.doc_format.name}")
                print(f"Version:      \t {doc.info.version}")
                print(f"Category Name:\t {doc.info.doc_class.name}")
                print(f"Encrypted:    \t {doc.info.encrypted}")

    except kv.KeyViewError as e:
        print(e)

For information about mapping detected formats to document readers, see File Formats and Document Readers.

Copyright 1997-2024 Open Text
Version 24.3 | Last updated June 2024

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: IDOL KeyView 24.3

Topic Title: Obtain Format Information