Hi support,
I'm testing your product (FreeSpire.Doc nuget package) to see if it is a tool that we want to purchase.
The use case is to download any URL (file type is not known e.g. see attachment) and use Aspire to:
1) Autodetect file type (could be any e.g. pdf, doc/x, xls/x etc.)
2) Convert file (contents) to plain text
I have included my source code below but the problem is that I get an exception when trying to load the file via the Url:
"this is not a structured storage file"
Source code:
HttpClient client = new HttpClient();
Document document = new Document();
using (var file = await client.GetStreamAsync(url).ConfigureAwait(false)) // E.g. url =
using (var memoryStream = new MemoryStream())
{
await file.CopyToAsync(memoryStream);
document.LoadFromStream(memoryStream, FileFormat.Auto);
}
// Get type
FileFormat fileExtension = document.DetectedFormatType;
// Save source to Text using a stream
MemoryStream streamResult = new MemoryStream();
// Populate stream
document.SaveToStream(streamResult, FileFormat.Txt);
// Get text string
string textContent = Encoding.ASCII.GetString(streamResult.ToArray()); ;
Thank you in advance for your reply.