Image RelativeHorizontalPosition does not set correctly in ODT using C#

Hi!

I’m testing to see if we can use Aspose.Words in a project. In the code in question, we have to position an image in the center of the right margin. Here is the code:

        var doc = new Document(fileName);

        DocumentBuilder builder = new DocumentBuilder(doc);

        builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);

        var shape = builder.InsertImage(image, RelativeHorizontalPosition.RightMargin, 0.0, RelativeVerticalPosition.Page, 0.0, 40.0, 292.0, WrapType.None);

        shape.VerticalAlignment = VerticalAlignment.Center;
        shape.HorizontalAlignment = HorizontalAlignment.Center;

        doc.Save(outfile);

This code is working normally for .DOC, .DOCX, .RTF and .PDF formats, however, in .ODT format the image is in the center of the page instead of the center of the right margin.

Is there anything I can do to correct this problem, or is it a lib error?

@sinoinformatica

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

  • Please attach the output file that shows the undesired behavior.
  • Please attach the expected output file that shows the desired behavior.
  • Please attach the image file that you want to insert into document.

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

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

OdtImageRightMarginAligned.zip (234.6 KB)

@sinoinformatica

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-21204 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

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