We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Empty text will lead to NullReferenceException


My customer has done some test in this .NET update and this Java update.

But when the text is empty ( click the mouse right button——create a new text without typing anything), converting txt to xps will lead to NullReferenceException.

Please help me solve the problem as soon as possible.

Many thanks

Thanks for your inquiry. The file created by using (right-click > new > Word Doc) has file size 0k. This is not a bug in Aspose.Words. In this case, the file with zero length has no header. All object files have the header by which one can understand that the format and version of the format.

In .TXT file format, there is no such header. So if the file size is zero, we can not be sure about its format. You can check the file size before loading it into Aspose.Words.Document.

FileInfo f = new FileInfo(MyDir + "in.txt");

long size = f.Length;

Hope this answers your query. Please let us know if you have any more queries.