Aspose::Words::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.

class FileFormatUtil

Methods

MethodDescription
static ContentTypeToLoadFormat(const System::String&)Converts IANA content type into a load format enumerated value.
static ContentTypeToSaveFormat(const System::String&)Converts IANA content type into a save format enumerated value.
static DetectFileFormat(const System::String&)Detects and returns the information about a format of a document stored in a disk file.
static DetectFileFormat(const System::SharedPtr<System::IO::Stream>&)Detects and returns the information about a format of a document stored in a stream.
static DetectFileFormat(std::basic_istream<CharType, Traits>&)
static ExtensionToSaveFormat(const System::String&)Converts a file name extension into a SaveFormat value.
FileFormatUtil()
static ImageTypeToExtension(Aspose::Words::Drawing::ImageType)Converts an Aspose.Words image type enumerated value into a file extension. The returned extension is a lower-case string with a leading dot.
static LoadFormatToExtension(Aspose::Words::LoadFormat)Converts a load format enumerated value into a file extension. The returned extension is a lower-case string with a leading dot.
static LoadFormatToSaveFormat(Aspose::Words::LoadFormat)Converts a LoadFormat value to a SaveFormat value if possible.
static SaveFormatToExtension(Aspose::Words::SaveFormat)Converts a save format enumerated value into a file extension. The returned extension is a lower-case string with a leading dot.
static SaveFormatToLoadFormat(Aspose::Words::SaveFormat)Converts a SaveFormat value to a LoadFormat value if possible.

Examples

Shows how to detect encoding in an html file.

SharedPtr<FileFormatInfo> info = FileFormatUtil::DetectFileFormat(MyDir + u"Document.html");

ASSERT_EQ(LoadFormat::Html, info->get_LoadFormat());

// The Encoding property is used only when we create a FileFormatInfo object for an html document.
ASSERT_EQ(u"Windows-1252", info->get_Encoding()->get_WebName());
ASSERT_EQ(1252, info->get_Encoding()->get_CodePage());

See Also