DocumentConverterCanConvert(String, String, NullableDocumentEngine) Method

Gets a value that indicates whether a direct conversion is possible from one document file to another file.

Definition

Namespace: GleamTech.DocumentUltimate
Assembly: GleamTech.DocumentUltimate (in GleamTech.DocumentUltimate.dll) Version: 6.9.7
C#
public static bool CanConvert(
	string inputFile,
	string outputFile,
	DocumentEngine? engine = null
)

Parameters

inputFile  String
The file name or path or extension (with or without leading dot) of the document file to convert.
outputFile  String
The file name or path or extension (with or without leading dot) of the converted document file.
engine  NullableDocumentEngine  (Optional)
The document engine to force. If not specified, the best document engine will be chosen automatically according to the input and output formats.

Return Value

Boolean
true if a direct conversion is possible; otherwise, false.

Example

Use static CanConvert method to check beforehand if an input document can be directly converted another format:

C#
// CanConvert determines document format from the extension in file name.
// So it does not read the file to check if it's a valid Docx file.
if (DocumentConverter.CanConvert(@"c:\SomeFolder\InputFile.docx", DocumentFormat.Pdf))
    DocumentConverter.Convert(@"c:\SomeFolder\InputFile.docx", DocumentFormat.Pdf);

// This check is same as above
if (DocumentConverter.CanConvert(@"c:\SomeFolder\InputFile.docx", "OutputFile.pdf"))
    DocumentConverter.Convert(@"c:\SomeFolder\InputFile.docx", DocumentFormat.Pdf);

// This check is same as above
if (DocumentConverter.CanConvert(DocumentFormat.Docx, DocumentFormat.Pdf))
    DocumentConverter.Convert(@"c:\SomeFolder\InputFile.docx", DocumentFormat.Pdf);

See Also