ImportFormatOptionsIgnoreTextBoxes Property |
Namespace: Aspose.Words
// Create a document and add text Document dstDoc = new Document(); DocumentBuilder builder = new DocumentBuilder(dstDoc); builder.Writeln("Hello world! Text box to follow."); // Create another document with a textbox, and insert some formatted text into it Document srcDoc = new Document(); builder = new DocumentBuilder(srcDoc); Shape textBox = builder.InsertShape(ShapeType.TextBox, 300, 100); builder.MoveTo(textBox.FirstParagraph); builder.ParagraphFormat.Style.Font.Name = "Courier New"; builder.ParagraphFormat.Style.Font.Size = 24.0d; builder.Write("Textbox contents"); // When we import the document with the textbox as a node into the first document, by default the text inside the text box will keep its formatting // Setting the IgnoreTextBoxes flag will clear the formatting during importing of the node ImportFormatOptions importFormatOptions = new ImportFormatOptions(); importFormatOptions.IgnoreTextBoxes = true; NodeImporter importer = new NodeImporter(srcDoc, dstDoc, ImportFormatMode.KeepSourceFormatting, importFormatOptions); ParagraphCollection srcParas = srcDoc.FirstSection.Body.Paragraphs; foreach (Node node in srcParas) { Paragraph srcPara = (Paragraph) node; Node importedNode = importer.ImportNode(srcPara, true); dstDoc.FirstSection.Body.AppendChild(importedNode); } dstDoc.Save(ArtifactsDir + "DocumentBuilder.IgnoreTextBoxes.docx");