I have project files with multiple tasks where each task contain text or MS Word notes. Retrieving text notes is quite easy, but no information is available for getting MS Word documents from the task notes.
Can you provide some sample code to retrieve the MS Word doc from task note?
Hi Mark,
Thank you for writing to us.
I am afraid to inform you that Aspose.Tasks API doesn’t support retrieving any type of documents from a Task’s Notes. However, in order to log it as a new feature request, we need to know your exact requirements such as:
- What is the Notes structure
- Whether Notes contain a single embedded object or a list of objects
- Embedded objects are of same type or mixture of text and objects, etc.
If you could please provide us detail requirements, we may look into the possible implementation of extracting embedded objects as a stream as we can’t provide facility to parse every type of object (as it lies out of our product’s scope). Your provided information will help us plan this feature for implementation in our upcoming versions.
Hi Kashif,
Thanks for prompt response.
My users send me MPP files where tasks contain notes. Sometimes these notes are in the form of Doc object. I need to extract those doc objects from the notes. I am attaching a sample MPP file where first task contains a note. When you open this note, it shows Word doc with picture. I need this doc file to be extracted from the note. Normally they send one single type of object in the note i.e. Word file.
Hope this will answer your query.
Hi Mark,
Thank you for the feedback.
You can use Aspose.Tasks in combination with Aspose.Words to utilize the NotesRTF of a task for extraction of your required docs from Task’s Notes. Please have a look at the following code sample for your reference that fulfills your requirements. I have also attached a sample project here for your reference. Please let us know if we can be of any additional help in this regard.
Sample Code:
ProjectReader reader = new ProjectReader();
Project project = reader.Read("Project1.mpp");
Task task = project.GetTaskById(1);
File.WriteAllText("Notes.rtf", task.NotesRTF);
Document doc = null;
using (MemoryStream stream = new MemoryStream())
using (StreamWriter streamWriter = new StreamWriter(stream))
{
streamWriter.Write(task.NotesRTF);
doc = new Document(stream);
}
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
foreach (Shape shape in shapes)
{
if (shape.OleFormat != null)
{
if (!shape.OleFormat.IsLink)
{
//Extract OLE Word object
if (shape.OleFormat.ProgId == "Word.Document.12")
{
MemoryStream stream = new MemoryStream();
shape.OleFormat.Save(stream);
Document newDoc = new Document(stream);
newDoc.Save("Embedded doc.doc");
}
}
}
}