1
How to check file is supported or not?
Question asked by AHMED A - January 16 at 12:30 PM
Answered
hello,
 
How can I check if file is supported in documentultimate or not?
 
thank you

1 Reply

Reply to Thread
0
Cem Alacayir Replied
January 16 at 12:41 PM
Employee Post
We recently added 2 new examples for this purpose, you can test all possible conversions on our Live Demo (or when you run the bundled examples project locally):
 
 
 
If you are asking how to do it programmatically:
 
  • You can use static CanConvert method to check beforehand if an input document can be directly converted another format.
     
    if (DocumentConverter.CanConvert("MyDocument.docx", DocumentFormat.Pdf))
    {
        // ...
    }
     
  • You can enumerate possible output document formats for a given input document file with EnumeratePossibleOutputFormats method and vice versa with EnumeratePossibleInputFormats method:
     
    foreach (var outputFormat in DocumentConverter.EnumeratePossibleOutputFormats(inputDocument))
    {
        // ...
    }
     
    foreach (var inputFormat in DocumentConverter.EnumeratePossibleInputFormats(outputDocument))
    {
        // ...
    }
     
  • ​You can also 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.
     
    var documentConverter = new DocumentConverter("MyDocument.xlsx");
    documentConverter.ConvertTo(DocumentFormat.Pdf);
    documentConverter.ConvertTo("MyDocument.xps");
    var result  = documentConverter.ConvertTo(DocumentFormat.Jpg);
    if (documentConverter.CanConvertTo(DocumentFormat.Html))
    {
        // ...    
    }

Reply to Thread