Free Support Forum - aspose.com

DocumentBuilder drawing Table with Footer settings?

Hi guys,

I'm having a problem with formatting of my Tables, which I'm creating using DocumentBuilder. In brief, I am doing the following with Aspose :

1. Load a word template (.doc file)

2. Use "GetFieldNames" to extract a list of the MergeField names in the document

3. Traverse the list of names and use "MoveToMergeField" for each

4. Depending on the name of the field, I will either update the text or write a Table

The result of which is then streamed out to the client. For the most part, all is well except that if in step (3) one of my MergeFields sits in the Footer of the page, then any Table that I write out (using DocumentBuilder) automatically takes on part of the Footer formatting (ie; a dull grey line).

I am using Aspose.Words 3.5.1.0 (having only recently upgraded from 2.3.3.0).

To make my problem easier to understand, I've attached a sample project that illustrates the issue. The file "ExecutiveSummary.doc" is my template and the project will produce a "GoodResult.doc" and "BadResult.doc" when run. If you look at the table just above the heading "Recommendations Summary" on the "BadResult.doc" page, you will see the grey line I am referring to.

I've spent some time looking through the forum already today .... in addition to playing around with as many formatting features as I could alter .... and I'm still stuck.

Your assistance is greatly appreciated.

Regards

Jason Barr.

First of all thank you for extremely well prepared and rich commented test project that you have sent us. It made working with the defect a real pleasure.

The behavior you describe is indeed unwelcome. We will discuss with the rest of the team if this is 'by design' or not and could we possibly fix it quickly.

The defect is logged as Issue #868. We will be able to deal with it in 1-2 weeks. You'll be informed of the results here in this thread.

Meanwhile, you can use the following workaround. Try resetting the DocumentBuilder.RowFormat.Borders properties explicitly.

For example in your case it will be:

DocumentBuilder.RowFormat.Borders[BorderType.Top].LineStyle = LineStyle.None

I see your point, thanks for the explanation. The current behaviour is by design.

RowFormat and CellFormat of DocumentBuilder are designed to be in "attached" or "detached" state.

When a cursor is moved into a table, RowFormat and CellFormat become "attached" to the table formatting that is avaialble in that location.

When you move the cursor out of a table, RowFormat and CellFormat become "detached" from the table, but they retain the old values.

It did not occur to me when designing, but what you suggest might be a better behaviour. That is for RowFormat and CellFormat to become "empty" when the cursor is moved out of a table. However I will leave this as an open issue for the time being. We might change it in the future.