Can't Extract the Objects embedded in Notes section of MPP file, which is inserted as link to other file


#1

Screenshot (9).png (78.3 KB)

I have inserted a .txt file as linked, to Mpp file. I am able to extract the same file, if it is inserted with Display Icon, but can’t extract the same file when inserted as linked with the same code.
I have used notesRtf and Aspose.words for extarcting the embedded objects. It worked with DISPLAY ICON, But not in case of LINk. Why is it so?
Link to my file


#2

@alishasharma

Can you please share source code for further investigation. Along with environment details and version of Aspose.Tasks which you are using on your end.


#3

var project = new Project(sourceFilePath);
IEnumerable<Aspose.Tasks.Task> task = project.SelectAllChildTasks();
TaskCollection tasks = project.RootTask.Children;
int imageindex = 0;
foreach (Aspose.Tasks.Task tsk in task)
{
var noteText = tsk.Get(Tsk.NotesText);
var noteRTF = tsk.Get(Tsk.NotesRTF);
if (noteRTF != null && noteRTF.Length > 0)
{
Aspose.Words.Document doc = null;
using (MemoryStream stream = new MemoryStream());
using (StreamWriter streamWriter = new StreamWriter(stream))
{
streamWriter.Write(noteRTF);
Aspose.Words.LoadOptions option = new Aspose.Words.LoadOptions();
option.LoadFormat = LoadFormat.Rtf;
doc = new Document(stream,option);
}
TaskCollection collection = tsk.Children;
int sectioncount = doc.Sections.Count;
for (int i = 0; i < sectioncount; i++)
{
Aspose.Words.Section section = doc.Sections[i];
Body body = section.Body;
Aspose.Words.ParagraphCollection para = body.Paragraphs;

                        foreach (Aspose.Words.Paragraph paragraph in para)
                        {
                            Node curNode = paragraph.FirstChild;
                            while (curNode != null)
                            {
                                Node nextNode = curNode.NextSibling;
                                if (curNode.NodeType.Equals(NodeType.Shape))
                                {
                                    Aspose.Words.Drawing.Shape shape =(Aspose.Words.Drawing.Shape)curNode;
                                    Aspose.Words.Drawing.OleFormat OleFormat = shape.OleFormat;
                                    if (shape.ImageData != null)
                                    {
                                        if (shape.OleFormat != null)
                                        {
                                            if(!string.IsNullOrEmpty(shape.OleFormat.SuggestedExtension))
                                            {
                                                shape.OleFormat.Save(destinationpath + 
                                               String.Format(embeddedfilename, embeddedfileindex, 
                                                 shape.OleFormat.SuggestedExtension));
                                            }
                                           
                                            embeddedfileindex++;
                                        }
                                        else
                                        {
                                            if (shape.HasImage)
                                            {
                                                string imagepath = destinationpath + string.Format("image_{0}.{1}", imageindex, shape.ImageData.ImageType);
                                                using (FileStream fess = new FileStream(imagepath, FileMode.Create))
                                                {

                                                    shape.ImageData.Save(fess);

                                                    imageindex++;
                                                }
                                                count++;
                                            }

                                            embeddedfileindex++; 
                                        }
                                    }
                                }
                                curNode = nextNode;
                            }
                        }
                    }

This is the sample code that extracts the objects embedded with displayicon, doesnt extracts the objects place with Link. Please check the file mentioned above with this code. And let me know, the changes that i need to make for such objects’ extraction.


#4

@alishasharma,

I have worked with sample code shared by you. Can you please share complete working sample project. 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.