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

Free Support Forum - aspose.com

Incorrect cell width (before save is called)

Hello,

i got an issue again, that I had to fight last year. I do not remember how I could solve it (probably by an aspose update). But it’s back and I hope you know that issue or you can help to unterstand whats going on.

I use a method the calculate an image size depending on if its in a table cell or not.

 if (cell != null)
        {
            maxWidth = cell.CellFormat.Width;
            maxHeight = maxWidth;
        }
        else
        {
            var ps = builder.CurrentSection.PageSetup;
            maxHeight = (ps.PageHeight - ps.TopMargin - ps.BottomMargin) * heightMultiplicator;
            maxWidth = ps.PageWidth - ps.LeftMargin - ps.RightMargin;
        }

In some cases the tests are failing, because cell.CellFormat.Width does contain a wrong value.

What we figured out is, that aftter calling document.save() the property is set with the correct value. Also when debugging, and populating the document in visual studio (via reflection) the width will be set correctly. It looks like there is a bug with updating some props.

As a workaround I do a doc.Save into a memory stream, before i use a replace evaluator to manipulate the document. I suppose that the Save-Method traverses the document object and thats why the width property in the document is set correctely after that.

hopefully you’ve got an advice how to handle it… This cannot be the solution…

Kind regards,
Holger

@holger.kreissl,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.