DocumentConverterCanConvertTo(DocumentFormat, NullableDocumentEngine) Method

Gets a value that indicates whether a direct conversion is possible to the specified format.

Definition

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

Parameters

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

Create an instance of DocumentConverter class with an input document and call instance methods ConvertTo and CanConvertTo. This is useful especially when you want to convert the same input document to several output formats:

C#
var documentConverter = new DocumentConverter(@"c:\SomeFolder\InputFile.docx");

// CanConvertTo 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.CanConvertTo(DocumentFormat.Pdf))
    documentConverter.ConvertTo(DocumentFormat.Pdf);

// This check is same as above
if (documentConverter.CanConvertTo("OutputFile.pdf"))
    documentConverter.ConvertTo(DocumentFormat.Pdf);

See Also