Hi Kannan,
Thanks for your inquiry.
*kannan.subramanian:
- Creating an word document (DOCX format) with images, Inline tables, Book marks, Embeded Object (Excel) file.*
Please use the following code snippet to create document (Docx) with image, inline tables and bookmark. Regarding Embedded object, Unfortunately, inserting new OLE objects into Word documents and updating existing OLE objects is not supported at the moment.
We had already logged this feature request as WORDSNET-1206 in our issue tracking system. I have linked this forum thread to the same feature and you will be notified via this forum thread once this feature is available. We apologize for your inconvenience.
//Create empty document
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert image
builder.Write("Image from local file: ");
builder.InsertImage(MyDir + "Aspose.jpg");
builder.Writeln();
builder.Write("Image from an internet url, automatically downloaded for you: ");
builder.InsertImage("http://www.aspose.com/Images/aspose-logo.jpg");
builder.Writeln();
builder.Writeln();
// create a new bookmark.
builder.StartBookmark("MyBookmark");
builder.Writeln("Text inside a bookmark.");
builder.EndBookmark("MyBookmark");
builder.InsertBreak(BreakType.PageBreak);
// We call this method to start building the table.
builder.StartTable();
builder.InsertCell();
builder.Write("Row 1, Cell 1 Content.");
// Build the second cell
builder.InsertCell();
builder.Write("Row 1, Cell 2 Content.");
// Call the following method to end the row and start a new row.
builder.EndRow();
// Build the first cell of the second row.
builder.InsertCell();
builder.Write("Row 2, Cell 1 Content");
// Build the second cell.
builder.InsertCell();
builder.Write("Row 2, Cell 2 Content.");
builder.EndRow();
// Signal that we have finished building the table.
builder.EndTable();
doc.Save(MyDir + "AsposeOut.docx");
Please read following documentation links for your kind reference.
https://docs.aspose.com/words/net/document-builder-overview/
https://docs.aspose.com/words/net/document-builder-overview/
https://docs.aspose.com/words/net/introduction-and-creating-tables/
https://docs.aspose.com/words/net/working-with-bookmarks/
kannan.subramanian:
2. Modifying / updating the existing contents (image, inline table, book marks, embeded object) of the word document.
Please use the following code snippet to replace an image.
// Replace shape image
Document doc = new Document(MyDir + "in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = (Shape) doc.GetChild(NodeType.Shape, 0, true);
shape.ImageData.SetImage(MyDir + @"AsposeOut.001.jpeg");
doc.Save(MyDir + "AsposeOut.docx");
Following example shows how to get or set bookmark name and text.
Document doc = new Document(MyDir + "Bookmark.doc");
// Use the indexer of the Bookmarks collection to obtain the desired bookmark.
Bookmark bookmark = doc.Range.Bookmarks["MyBookmark"];
// Get the name and text of the bookmark.
string name = bookmark.Name;
string text = bookmark.Text;
// Set the name and text of the bookmark.
bookmark.Name = "RenamedBookmark";
bookmark.Text = "This is a new bookmarked text.";
Please read the detail from following documentation link to work with tables.
https://docs.aspose.com/words/net/working-with-tables/
You can use Node.Remove method to delete the DrawingML node. Please see the code below:
Document doc = new Document(MyDir + "in.docx");
DrawingML drawingML = (DrawingML) doc.GetChild(NodeType.DrawingML, 0, true);
drawingML.Remove();
doc.Save(MyDir + "AsposeOut.docx");
Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.