DocumentConverter.CanConvert Method
Definition
- Namespace
- GleamTech.DocumentUltimate
- Assembly
- GleamTech.DocumentUltimate.dll
CanConvert(DocumentFormat, DocumentFormat, DocumentEngine?)
Gets a value that indicates whether a direct conversion is possible from one document format to another format.
public static bool CanConvert(DocumentFormat inputFormat, DocumentFormat outputFormat, DocumentEngine? engine = null)
Parameters
inputFormatDocumentFormatThe format to convert from
outputFormatDocumentFormatThe format to convert to.
engineDocumentEngine?The document engine to force. If not specified, the best document engine will be chosen automatically according to the input and output formats.
Returns
- bool
true if a direct conversion is possible; otherwise, false.
Examples
Use static CanConvert method to check beforehand if an input document can be directly converted another format:
// 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);
' 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) Then
DocumentConverter.Convert("c:\SomeFolder\InputFile.docx", DocumentFormat.Pdf)
End If
' This check is same as above
If DocumentConverter.CanConvert("c:\SomeFolder\InputFile.docx", "OutputFile.pdf") Then
DocumentConverter.Convert("c:\SomeFolder\InputFile.docx", DocumentFormat.Pdf)
End If
' This check is same as above
If DocumentConverter.CanConvert(DocumentFormat.Docx, DocumentFormat.Pdf) Then
DocumentConverter.Convert("c:\SomeFolder\InputFile.docx", DocumentFormat.Pdf)
End If
CanConvert(string, DocumentFormat, DocumentEngine?)
Gets a value that indicates whether a direct conversion is possible from one document file to another format.
public static bool CanConvert(string inputFile, DocumentFormat outputFormat, DocumentEngine? engine = null)
Parameters
inputFilestringThe file name or path or extension (with or without leading dot) of the document file to convert.
outputFormatDocumentFormatThe format to convert to.
engineDocumentEngine?The document engine to force. If not specified, the best document engine will be chosen automatically according to the input and output formats.
Returns
- bool
true if a direct conversion is possible; otherwise, false.
Examples
Use static CanConvert method to check beforehand if an input document can be directly converted another format:
// 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);
' 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) Then
DocumentConverter.Convert("c:\SomeFolder\InputFile.docx", DocumentFormat.Pdf)
End If
' This check is same as above
If DocumentConverter.CanConvert("c:\SomeFolder\InputFile.docx", "OutputFile.pdf") Then
DocumentConverter.Convert("c:\SomeFolder\InputFile.docx", DocumentFormat.Pdf)
End If
' This check is same as above
If DocumentConverter.CanConvert(DocumentFormat.Docx, DocumentFormat.Pdf) Then
DocumentConverter.Convert("c:\SomeFolder\InputFile.docx", DocumentFormat.Pdf)
End If
CanConvert(string, string, DocumentEngine?)
Gets a value that indicates whether a direct conversion is possible from one document file to another file.
public static bool CanConvert(string inputFile, string outputFile, DocumentEngine? engine = null)
Parameters
inputFilestringThe file name or path or extension (with or without leading dot) of the document file to convert.
outputFilestringThe file name or path or extension (with or without leading dot) of the converted document file.
engineDocumentEngine?The document engine to force. If not specified, the best document engine will be chosen automatically according to the input and output formats.
Returns
- bool
true if a direct conversion is possible; otherwise, false.
Examples
Use static CanConvert method to check beforehand if an input document can be directly converted another format:
// 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);
' 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) Then
DocumentConverter.Convert("c:\SomeFolder\InputFile.docx", DocumentFormat.Pdf)
End If
' This check is same as above
If DocumentConverter.CanConvert("c:\SomeFolder\InputFile.docx", "OutputFile.pdf") Then
DocumentConverter.Convert("c:\SomeFolder\InputFile.docx", DocumentFormat.Pdf)
End If
' This check is same as above
If DocumentConverter.CanConvert(DocumentFormat.Docx, DocumentFormat.Pdf) Then
DocumentConverter.Convert("c:\SomeFolder\InputFile.docx", DocumentFormat.Pdf)
End If