Extracting embedded Image objects in notes section of MPP (C# .NET)

I am not able to extract the image objects from notes section, but other word, excel and ppt files are extracted.

@alishasharma,

Can you please share source file along with sample code so that we may further investigate to help you out.

//view section
OleObjectCollection oleobjectcollection = null;
oleobjectcollection = project.OleObjects;
if (oleobjectcollection != null)
{
foreach (OleObject oleobject in oleobjectcollection)
{
if (!string.IsNullOrEmpty(oleobject.FileFormat))
{
if (oleobject.Label != null || oleobject.FullPath != null)
{
string fileformat = oleobject.FullPath.Remove(0, oleobject.FullPath.IndexOf(".") + 1);
string newfilename = string.Format(embeddedfilename, embeddedfileindex, fileformat);
string appname = oleobject.ApplicationName;
WriteToFile(oleobject, newfilename);
}

                   else if (!string.IsNullOrEmpty(oleobject.FileFormat) && fileFormatExt.ContainsKey(oleobject.ApplicationName.ToLower()))
                    {
                        if (oleobject.Content != null)
                        {
                            string path = destinationpath + (string.Format("EmbeddedContent_{0}", fileFormatExt[oleobject.ApplicationName.ToLower()]));
                            using (FileStream fileStream = new FileStream(path, FileMode.Create))
                                fileStream.Write(oleobject.Content, 0, oleobject.Content.Length);
                        }

                    }

                }
            }

//for notes section
IEnumerable<Aspose.Tasks.Task> task = project.SelectAllChildTasks();
TaskCollection tasks = project.RootTask.Children;
foreach (Aspose.Tasks.Task tsk in task)
{
Aspose.Tasks.Task tk = project.RootTask.Children.GetById(11);
var noteText = tsk.Get(Tsk.NotesText);
var noteRTF = tsk.Get(Tsk.NotesRTF);
if (noteRTF != null && noteRTF.Length > 0)
{
Aspose.Words.Document doc = null;
using (FileStream stream = new FileStream(destinationpath + “abc.txt”, FileMode.OpenOrCreate))
{
using (StreamWriter streamWriter = new StreamWriter(stream))
{
streamWriter.Write(tsk.Get(Tsk.NotesRTF));
doc = new Aspose.Words.Document(stream);
}
}
Aspose.Words.NodeCollection shapes = doc.GetChildNodes(Aspose.Words.NodeType.Shape, true);
foreach (Aspose.Words.Drawing.Shape shape in shapes)
{
if (shape.OleFormat != null)
{
if (!shape.OleFormat.IsLink)
{
string fileName = (string.IsNullOrEmpty(shape.OleFormat.SuggestedFileName) ? “NO_FILENAME” : shape.OleFormat.SuggestedFileName) + shape.OleFormat.SuggestedExtension;
FileStream fstream = new FileStream(destinationpath +
fileName,FileMode.OpenOrCreate);
MemoryStream ms = new MemoryStream();
shape.OleFormat.Save(ms);
shape.OleFormat.Save(fstream);
string id = shape.OleFormat.ProgId;
var fileSize = ms.Length;
byte[] count = BitConverter.GetBytes(fileSize);
}
}

@alishasharma,

I have observed your comments. Can you please share complete working code snippet. The code snippet you have shared includes some undeclared variables so would you please share SSCCE code reproducing the issue so that we may try to reproduce and investigate it in our environment. Also please share source file as well.