FileFormatUtil class
FileFormatUtil class
Provides utility methods for working with file formats, such as detecting file format or converting file extensions to/from file format enums. To learn more, visit the Detect File Format and Check Format Compatibility documentation article.
Methods
Name | Description |
---|---|
content_type_to_load_format(content_type) | Converts IANA content type into a load format enumerated value. |
content_type_to_save_format(content_type) | Converts IANA content type into a save format enumerated value. |
detect_file_format(file_name) | Detects and returns the information about a format of a document stored in a disk file. |
detect_file_format(stream) | Detects and returns the information about a format of a document stored in a stream. |
extension_to_save_format(extension) | Converts a file name extension into a SaveFormat value. |
image_type_to_extension(image_type) | Converts an Aspose.Words image type enumerated value into a file extension. The returned extension is a lower-case string with a leading dot. |
load_format_to_extension(load_format) | Converts a load format enumerated value into a file extension. The returned extension is a lower-case string with a leading dot. |
load_format_to_save_format(load_format) | Converts a LoadFormat value to a SaveFormat value if possible. |
save_format_to_extension(save_format) | Converts a save format enumerated value into a file extension. The returned extension is a lower-case string with a leading dot. |
save_format_to_load_format(save_format) | Converts a SaveFormat value to a LoadFormat value if possible. |
Examples
Shows how to detect encoding in an html file.
info = aw.FileFormatUtil.detect_file_format(MY_DIR + "Document.html")
self.assertEqual(aw.LoadFormat.HTML, info.load_format)
# The "encoding" property is used only when we create a FileFormatInfo object for an html document.
self.assertEqual("windows-1252", info.encoding)
See Also
- module aspose.words