DocumentConverterCanConvert(DocumentFormat, DocumentFormat, NullableDocumentEngine) Method

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

Definition

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

Parameters

inputFormat  DocumentFormat
The format to convert from
outputFormat  DocumentFormat
The format to convert to.
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