We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Textbox's text does not move to next linked Textbox After linking them using .NET

Hi Aspose Team,

I have a question regarding link between textboxes. Please see following code:

        var document = new Document();
        var builder = new DocumentBuilder(document);

        var box1 = builder.InsertShape(ShapeType.TextBox, 100, 100);
        var para = box1.AppendChild(new Paragraph(document));
        builder.MoveTo(para);
        for (int i = 0; i < 20; i++)
        {
            builder.Writeln("Some text");
        }
        builder.MoveToDocumentEnd();
        var box2 = builder.InsertShape(ShapeType.TextBox, 300, 300);
        box1.TextBox.Next = box2.TextBox;
        document.Save(@"TextBoxTest.docx");

In output document text is only added to first text box, and despite the fact that it’s overflowed - the second text box remains empty. In Word linking causes text to be moved between text boxes even if one of them is already filled with text.
I’m getting the same result even if I link text boxes first, and only then insert text to the first one.
Following code:

box1.TextBox.IsValidLinkTarget(box2.TextBox);

return true, so they should be linked correctly. Could you please help me out with this?

Thanks,
Mateusz

@acturisaspose

We have reproduced this issue and logged it in our issue tracking system as WORDSNET-20630 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-20630) have been fixed in this Aspose.Words for .NET 20.9 update and this Aspose.Words for Java 20.9 update.

Hi,

I created document using the code which was provided earlier, but when I am trying to open it, I’m getting error:
TextboxError.JPG (14.5 KB)

Could you check please?

Thanks,
Mateusz

@acturisaspose

Please use OoxmlSaveOptions.Compliance property as shown below to get the desired output.

OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.Compliance = OoxmlCompliance.Iso29500_2008_Transitional;

document.Save(MyDir + @"20.9.docx", saveOptions);

Thanks for reply.
I could open document now, but I can see only 1st textbox and when I tried to move it, then I noticed message:
MovingError.JPG (8.6 KB)

After clicking ‘OK’, Word crashed.

Could you check, please?

Thanks,
Mateusz

@acturisaspose

We have tested the scenario using the following code example and have managed to reproduce the same issue. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-21215 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

var document = new Document();
var builder = new DocumentBuilder(document);

var box1 = builder.InsertShape(ShapeType.TextBox, 100, 100);
var para = box1.AppendChild(new Paragraph(document));
builder.MoveTo(para);
for (int i = 0; i < 20; i++)
{
    builder.Writeln("Some text");
}
builder.MoveToDocumentEnd();
var box2 = builder.InsertShape(ShapeType.TextBox, 300, 300);
box1.TextBox.Next = box2.TextBox;

OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.Compliance = OoxmlCompliance.Iso29500_2008_Transitional;

document.Save(MyDir + @"20.9.docx", saveOptions);