Provides utility methods for working with file formats, such as detecting file format or converting file extensions to/from file format enums.
Shows how to detect encoding in an html file.
#include <Aspose.Words.Cpp/FileFormatUtil.h>
Public Member Functions | |
FileFormatUtil () | |
Static Public Member Functions | |
static LoadFormat | ContentTypeToLoadFormat (String contentType) |
Converts IANA content type into a load format enumerated value. More... | |
static SaveFormat | ContentTypeToSaveFormat (String contentType) |
Converts IANA content type into a save format enumerated value. More... | |
static SharedPtr< FileFormatInfo > | DetectFileFormat (SharedPtr< Stream > stream) |
Detects and returns the information about a format of a document stored in a stream. More... | |
static SharedPtr< FileFormatInfo > | DetectFileFormat (String fileName) |
Detects and returns the information about a format of a document stored in a disk file. More... | |
static SaveFormat | ExtensionToSaveFormat (String extension) |
Converts a file name extension into a SaveFormat value. More... | |
static String | ImageTypeToExtension (ImageType 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. More... | |
static String | LoadFormatToExtension (LoadFormat loadFormat) |
Converts a load format enumerated value into a file extension. The returned extension is a lower-case string with a leading dot. More... | |
static SaveFormat | LoadFormatToSaveFormat (LoadFormat loadFormat) |
Converts a LoadFormat value to a SaveFormat value if possible. More... | |
static String | SaveFormatToExtension (SaveFormat saveFormat) |
Converts a save format enumerated value into a file extension. The returned extension is a lower-case string with a leading dot. More... | |
static LoadFormat | SaveFormatToLoadFormat (SaveFormat saveFormat) |
Converts a SaveFormat value to a LoadFormat value if possible. More... | |
Aspose::Words::FileFormatUtil::FileFormatUtil | ( | ) |
|
static |
Converts IANA content type into a load format enumerated value.
System::ArgumentException | Throws when cannot convert. |
Shows how to find the corresponding Aspose load/save format from each media type string.
|
static |
Converts IANA content type into a save format enumerated value.
System::ArgumentException | Throws when cannot convert. |
Shows how to find the corresponding Aspose load/save format from each media type string.
|
static |
Detects and returns the information about a format of a document stored in a stream.
The stream must be positioned at the beginning of the document.
When this method returns, the position in the stream is restored to the original position.
Even if this method detects the document format, it does not guarantee that the specified document is valid. This method only detects the document format by reading data that is sufficient for detection. To fully verify that a document is valid you need to load the document into a Document object.
This method throws FileCorruptedException when the format is recognized, but the detection cannot complete because of corruption.
stream | The stream. |
Shows how to use the FileFormatUtil methods to detect the format of a document.
|
static |
Detects and returns the information about a format of a document stored in a disk file.
Even if this method detects the document format, it does not guarantee that the specified document is valid. This method only detects the document format by reading data that is sufficient for detection. To fully verify that a document is valid you need to load the document into a Document object.
This method throws FileCorruptedException when the format is recognized, but the detection cannot complete because of corruption.
fileName | The file name. |
Shows how to use the FileFormatUtil class to detect the document format and encryption.
Shows how to use the FileFormatUtil class to detect the document format and presence of digital signatures.
|
static |
Converts a file name extension into a SaveFormat value.
If the extension cannot be recognized, returns Unknown.
extension | The file extension. Can be with or without a leading dot. Case-insensitive. |
System::ArgumentNullException | Throws if the parameter is null. |
Shows how to use the FileFormatUtil methods to detect the format of a document.
|
static |
Converts an Aspose.Words image type enumerated value into a file extension. The returned extension is a lower-case string with a leading dot.
System::ArgumentException | Throws when cannot convert. |
Shows how to extract images from a document, and save them to the local file system as individual files.
|
static |
Converts a load format enumerated value into a file extension. The returned extension is a lower-case string with a leading dot.
The WordML value is converted to ".wml".
System::ArgumentException | Throws when cannot convert. |
Shows how to use the FileFormatUtil methods to detect the format of a document.
|
static |
Converts a LoadFormat value to a SaveFormat value if possible.
System::ArgumentException | Throws when cannot convert. |
Shows how to use the FileFormatUtil methods to detect the format of a document.
|
static |
Converts a save format enumerated value into a file extension. The returned extension is a lower-case string with a leading dot.
The WordML value is converted to ".wml".
The FlatOpc value is converted to ".fopc".
System::ArgumentException | Throws when cannot convert. |
Shows how to use the FileFormatUtil methods to detect the format of a document.
|
static |
Converts a SaveFormat value to a LoadFormat value if possible.
System::ArgumentException | Throws when cannot convert. |
Shows how to convert a save format to its corresponding load format.