Aspose.words does not recognize my embedded objects as nodetype == shape

Hi,
I have come across in some cases, when I look for embedded objects, it is not recoginizing the nodetype == shape. Does the header/footer interfere with this? In one small document, it recognizes a section type, a paragraph type, and a run type. But it does not recognize my embedded objects as a shape type. I need to extract these objects, but I am unsure if they are children or collections of a parent type? Have you had anyone have this trouble before?
Karen Schmidt

Hi

Thanks for your request. I used the following code for testing and it seems all works fine. I successfully extracted OLE objects from your document.

//Open document
Document doc = new Document(@"Test208\in.docx");
//get collection of shapes
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
int i = 0;
//Loop through all shapes
foreach (Shape shape in shapes)
{
    if (shape.OleFormat != null)
    {
        Console.WriteLine(shape.OleFormat.ProgId);
        //Extract OLE object
        if (shape.OleFormat.ProgId == "PowerPoint.Slide.8")
        {
            shape.OleFormat.Save(String.Format(@"Test208\out_{0}.ppt", i));
            i++;
        }
    }
}

I use the latest version of Aspose.Words (6.2.0) for testing.
Best regards.

Hi Alex, thank you for your prompt response. I am quite puzzled, because I am still having this problem. I have it occur with various files, I just sent you one of the smallest ones. I copied your code exactly, even renamed my file and hard-coded the filename to match exactly yours, and I deleted my aspose dll’s and redownloaded and referenced them. But I still have the problem occur, that no nodes are of nodetype.shape. If I change the nodecollection to nodetype.any, i print the node types of this file, and it is in a section and a body, with 3 paragraphs and 3 runs as children of the body, which is a child of the section. Do you have any idea why it would not detect a shape?

Hi

Thanks for your request. Most likely, you are using Aspose.Words in evaluation mode and your document is truncated. Try to open save your document using Aspose.Words. you will see the following message:
This document was truncated here because it was created using Aspose.Words in Evaluation Mode.
If you want to test Aspose.Words without the evaluation version limitations, you can request a 30-day Temporary License. Please refer to
https://purchase.aspose.com/temporary-license
Best regards.

Hi there,
For some reason, some of the objects are still not recognized. We are no longer in an Evaluation Mode and we are using a license now. I have the same results, using the following code, my count is 0, when it should be 13 embedded files.

int count = 0;
Aspose.Words.Document document = new Aspose.Words.Document(filename, Aspose.Words.LoadFormat.Auto,"");
Aspose.Words.NodeCollection nodes = document.GetChildNodes(Aspose.Words.NodeType.Shape, true);
if (nodes.Count > 0)
{
    foreach (Aspose.Words.Node node in nodes)
    if ((node as Aspose.Words.Drawing.Shape).OleFormat != null)
        count++;
}
return count;

Hi

Thanks for your request. Could you please attach your document for testing? I will investigate the issue and provide you more information.
Best regards.

Hi Alexey,
After doing a document.Save() I noticed the same message that the file was truncated due to the evaluation mode. After re-reading instructions on the licensing, I found that I needed to call the SetLicense() method, and my document is now being read correctly. I misunderstood the license intructions that the method call was only for Java Platforms. I am a .Net platform, and looks like I still need to call set it up like that also. I am no longer having a problem extracting my embedded files, and you can disregard my earlier email regarding our company policy requirement to be able to send you a file that you requested.
Thanks,
Karen Schmidt

Hi Karen,

It is nice that you have found the reason of the problem and resolved it.
Best regards.