Hi there,
We are currently trying to outline a strategy for detecting the Aspose component (starting from Detect file types from stream - #7 by codewarior) that could handle a stream based on utilities function like:
var fileFormatInfo = Aspose.Cells.FileFormatUtil.DetectFileFormat(input);
if (fileFormatInfo.LoadFormat != Aspose.Cells.LoadFormat.Unknown)
{
canHandle = true;
}
Aspose.PDF 20.3.0 does not have such utilities functions and the one that the aforementioned post suggests is:
try
{
input.Position = 0L;
using (var doc = new Aspose.Pdf.Document(input))
{
}
canHandle = true;
}
catch (Exception)
{
}
The problem is that this approach for Aspose.PDF is time/resource consuming and we were wondering if there are other ways to check this with the latest of Aspose.PDF:
- utilities like Aspose.Words.FileFormatUtil.DetectFileFormat(input) or even the Aspose.CAD.Image.CanLoad(input)
- at least the possibility to shallow-load a stream into a Document just for the purpose of checking if it is a stream that the component could handle
Thank you!