I'm trying to getting number of char with spaces on word document from an azure function. With some documents, the number of characters returned is negative
This is my code :
- Code: Select all
int nbPages = 0;
int nbChars = 0;
int nbCharsWithSpaces = 0;
using (var memory = new MemoryStream())
{
try
{
byte[] buffer = new byte[1024 * 64];
int nread = 0;
while ((nread = fileInfo.Stream.Read(buffer, 0, buffer.Length)) > 0)
{
memory.Write(buffer, 0, nread);
}
memory.Seek(0, SeekOrigin.Begin);
spireDoc.LoadFromStream( memory,FileFormat.Docx);
nbPages = spireDoc.GetPageCount();
nbCharsWithSpaces = spireDoc.BuiltinDocumentProperties.CharCountWithSpace;
nbChars = spireDoc.BuiltinDocumentProperties.CharCount;
log.Info("Nb pages with SPire.Doc=[" + nbPages + "]");
log.Info("Nb charac =[" + nbChars + "]");
log.Info("Nb charac with spaces=[" + nbCharsWithSpaces + "]");
And the result :
2021-06-17T21:09:04.786 [Info] Nb pages with SPire.Doc=[8]
2021-06-17T21:09:04.786 [Info] Nb charac =[-2147483648]
2021-06-17T21:09:04.786 [Info] Nb charac with spaces=[-2147483648]
PS : i use 7.8.8 Spire.Doc version
Any idea ?
Thanks