Archive for the ‘Document Handling’ Category

Aspose Document Text Formatting Messed Up

December 10, 2008

We are using Aspose to generate Word Documents using Templates that we have stored in Sharepoint.

The Bug
The users reported a bug in one particular generated document that some of the formatting in one of the templates was being lost during document generation i.e. we have a ConsolidatedWidgetReport Template.doc which is composed of WidgetInventoryTemplate.doc, GoCrazyForWidgets.doc, and WidgetMania.doc.

We use Aspose to insert data into the sub-templates and plonk the lot into ConsolidatedWidgetReport.doc. Somehow formatting in GoCrazyForWidgets.doc was being lost and otherwise messed up when viewed in ConsolidatedWidgetReport.doc.

It was horrible. Italic fields in the sub-template were being rendered non-italic. Bolding was being inverted such that bold fields were being rendered non-bold in the generated document and vice-versa. Most shockingly, text in table cells was hyper-left justified so that half of every sentence appeared hidden under the neighbouring table cell to the left. One of the juniour Graphic Designers, on seeing the carnage, had to be physically assisted back to her diamond-encrusted throne desk.

Clearly we were dealing with some kind of maniac.

Making Gotham City Safe Again

First we investigated the possibility that the Template was bored and was mucking up as a form of sociopathic amusement but this turned out to be a non-issue based on psychological projection of the alienation the programmer felt in relation to his labour and his interminable ennui. The boredom thesis didn’t fly. All suspicion fell on Aspose.

Rescuing The Innocent

Just as we were wheeling out the electric chair, I noticed something. The Microsoft Word document styles in the GoCrazyForWidgets sub-template were defined differently to those in the main template.
Header2 was italicized in the sub-template but not in the main template. Header3 was bolded in the sub-template but not in the main template. Also, Header3 was being used for table body text, leading the the hyper-justification problem.

The crime was solved. Aspose was NOT GUILTY.

We just updated the styles in GoCrazyForWidgets.doc to be consistent with thes tyles in ConsolidatedWidgetReport.doc and changed the styling in the table cells from Header3 to table body.

Moral Of The Story

If you are merging many small documents into one large document and the formatting gets screwed up along the way, make sure the document styles are consistent between all the documents and that the styles are being applied in a sensible manner. Dont fry the innocent.