ImportFormatOptionsIgnoreTextBoxes Property

Gets or sets a boolean value that indicates whether to ignore formatting in the text boxes of the source destination during the import. Default value is true.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntax
public bool IgnoreTextBoxes { get; set; }

Property Value

Type: Boolean
Examples
Shows how to manage formatting in the text boxes of the source destination during the import.
// 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");
See Also