DocumentConverterCanConvertTo(String, NullableDocumentEngine) Method

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

Definition

Namespace: GleamTech.DocumentUltimate
Assembly: GleamTech.DocumentUltimate (in GleamTech.DocumentUltimate.dll) Version: 7.1.5
C#
public bool CanConvertTo(
	string outputFile,
	DocumentEngine? engine = null
)

Parameters

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

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