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

Free Support Forum - aspose.com

InsertHtml setting incorrect paragraph formatting inside cells

Hi Aspose team,

during mail merge we have implemented a field merging callback. The actions it performs are as follows:

var builder = new DocumentBuilder(args.Document);
builder.MoveToField(args.Field, false);
var recordSetElement = args.FieldValue as RecordSetElement;
var html = string.Format(ComplexContentHtmlPattern, args.FieldValue);
builder.InsertHtml(html, true);
args.Field.Remove();

The problem is that merge field in template has margin set to -1cm. This is also causing the content of the cells in table to have the same margin, so first cm of the text is not visible inside table cells. Could you please please advice what can be changed in our implementation to correct this formatting? Please find inserted htlm, template, output and expected output attached:
asposeInsertHtml.zip (44.0 KB)

Thanks,
Mateusz

@acturisaspose

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-17858. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@acturisaspose

Thanks for your patience. We have completed the analysis of this issue. In your case, we suggest you please use the DocumentBuilder.InsertHtml(html, false) method to get the desired output.

var builder = new DocumentBuilder(args.Document);
builder.MoveToField(args.Field, false);
var recordSetElement = args.FieldValue as RecordSetElement;
var html = string.Format(ComplexContentHtmlPattern, args.FieldValue);
builder.InsertHtml(html, false);
args.Field.Remove();

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