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

Free Support Forum - aspose.com

Trying to put two DocumentBuilder.InsertField next to each other on same line

I am trying to have two Mergefields next to each other on the same line in a single cell within a table.
But if I try to do something like this:

builder.InsertField(" MERGEFIELD Field1");
builder.InsertField(" MERGEFIELD FIeld2);

The second mergefield will be inserted on a new line, when I need them to be on the same line right next to each other.

Is there a way to get multiple mergefields to display on the same line?

Unfortunately, we were unable to reproduce the same issue on our side. Please check the following code example and the produced output document:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

for (int i = 0; i < 4; i++)
    for (int j = 0; j < 5; j++)

builder.MoveToCell(0, 2, 3, 0);

builder.InsertField(" MERGEFIELD Field1");
builder.InsertField(" MERGEFIELD FIeld2");


out.docx (7.3 KB)

If you still face the problem, please attach your input document here for testing. We will investigate the issue and provide you information on it.

Thank you! Went back through my code and realized I was using builder.Writeln when I should have been using builder.Write

@bweiss444 It is perfect that you managed to find the problem and resolve it. Please feel free to ask in case of any issues, we are always glad to help.