Aspose check whether the document is empty

Hello,
I have a question about the aspose document. How do we check the aspose document is empty ?
Are there any methods that say, document is empty.

Currently, I use this asposeDocument.getText().trim() . Is this method reliable enough ?

Reason for this question is, we go thru the conversion process that converts the document into json and so. If we know the document is empty before hand, we dont go thru the said process at all . Appreciate your help here. Thanks.

Regards,
Karthick S

Hi Karthick,

Thanks for your inquiry. Please use the following code example to achieve your requirements. Let us know if you have any more queries.

Document doc = new Document(MyDir + "in.docx");
if (doc.toString(SaveFormat.TEXT).trim() == "")
{
    if (doc.getChildNodes(NodeType.SHAPE, true).getCount() == 0 && doc.getChildNodes(NodeType.DRAWING_ML, true).getCount() == 0)
    {
        System.out.println("Document is empty");
    }
}