public static bool CanConvert(
DocumentFormat inputFormat,
DocumentFormat outputFormat,
DocumentEngine? engine = null
)
Public Shared Function CanConvert (
inputFormat As DocumentFormat,
outputFormat As DocumentFormat,
Optional engine As DocumentEngine? = Nothing
) As Boolean
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