Text of Shape is rendered outside the TextBox when OoxmlSaveOptions.Compliance is Iso29500_2008_Strict using Java

When creating a group of shapes in which one object is directly in the other, the error occurs such that there is no possibility of stretching the inner element and no text appears in it.

Java Code:

import com.aspose.words.Font;
import com.aspose.words.Shape;
import com.aspose.words.*;

import java.awt.*;
import java.io.File;

public class Example {

    public static void main(String[] args) throws Exception {
        overlapping();
    }
    
    public static void overlapping() throws Exception {

        // Create empty docx
        com.aspose.words.Document doc = new Document();
        doc.removeAllChildren();
        Section section = new Section(doc);
        doc.appendChild(section);
        DocumentBuilder builder = new DocumentBuilder(doc);


        //Page setup
        PageSetup ps = builder.getPageSetup();
        ps.setPageWidth(595.275634765625);
        ps.setPageHeight(841.8897705078125);
        ps.setOrientation(Orientation.PORTRAIT);
        ps.setTopMargin(17.00787353515625);
        ps.setBottomMargin(28.346435546875);
        ps.setLeftMargin(17.00787353515625);
        ps.setRightMargin(28.34649658203125);

        // box 1
        Shape outerShape = new Shape(builder.getDocument(), ShapeType.TEXT_BOX);
        outerShape.setWrapType(WrapType.NONE);
        outerShape.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
        outerShape.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
        outerShape.appendChild(new Paragraph(builder.getDocument()));
        outerShape.setFillColor(new Color(255, 255, 0));
        outerShape.setStrokeColor(new Color(0, 0, 0));
        outerShape.getFill().setOpacity(1.0);
        outerShape.setStrokeWeight(1.0);
        outerShape.setBehindText(true);
        outerShape.setWidth(217.04967685008614);
        outerShape.setHeight(21.67716535433071);
        outerShape.setTop(185.6828435462291);
        outerShape.setLeft(85.53939170537033);
        outerShape.setZOrder(1);

        Run run = new Run(builder.getDocument(), "ValueInputGraph - Label:");
        Font runFont = run.getFont();
        runFont.setName("Dialog");
        runFont.setSize(10);
        runFont.setBold(false);
        runFont.setItalic(false);
        outerShape.getLastParagraph().appendChild(run);
        outerShape.getTextBox().setVerticalAnchor(TextBoxAnchor.MIDDLE);

        // Second box
        Shape inputField = new Shape(builder.getDocument(), ShapeType.TEXT_BOX);
        inputField.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
        inputField.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
        inputField.setWidth(ConvertUtil.millimeterToPoint(30.204787731170654));
        inputField.getTextBox().setFitShapeToText(true);
        inputField.setStroked(true);
        inputField.setFillColor(new Color(255, 255, 255));
        inputField.setHeight(12.450000000000001);
        inputField.setTop(189.79642622339446);
        inputField.setLeft(213.96919780641093);
        inputField.setZOrder(3);

        TextBox textBox = inputField.getTextBox();
        textBox.setInternalMarginRight(0);
        textBox.setInternalMarginLeft(0);
        textBox.setInternalMarginTop(0);
        textBox.setInternalMarginBottom(0);

        Run run2 = new Run(builder.getDocument(), "Inputtext");
        Font runFont2 = run2.getFont();
        runFont2.setName("Tahoma");
        runFont2.setSize(10);
        runFont2.setBold(false);
        runFont2.setItalic(false);
        inputField.appendChild(new Paragraph(builder.getDocument()));
        inputField.getLastParagraph().appendChild(run2);

        // group from 1 and 2 box
        GroupShape group = new GroupShape(builder.getDocument());
        group.appendChild(outerShape);
        group.appendChild(inputField);

        double height = outerShape.getHeight();
        double width = outerShape.getWidth();

        group.setTop(outerShape.getTop());
        group.setLeft(outerShape.getLeft());
        group.setWidth(width);
        group.setHeight(height);
        group.setDistanceLeft(0);
        group.setDistanceRight(0);
        group.setZOrder(outerShape.getZOrder());
        group.setAllowOverlap(true);
        group.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
        group.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);
        group.setCoordSize(new Dimension((int) Math.ceil(width),(int) Math.ceil(height)));

        builder.insertNode(group);

        OoxmlSaveOptions options = new OoxmlSaveOptions();
        options.setCompliance(OoxmlCompliance.ISO_29500_2008_STRICT);
        doc.save(System.getProperty("user.dir") + File.separator + "overlap.docx",options);


    }
}

Reproduce result: run code
Expected result: In result file (after run code) in MsWord click on "ValueInputGraph " —> Shape Format --> Group Objects --> Ungroup --> Group Objects --> Group

In addition, I would like to know how you can lock the possibility of editing individual shapes.
Like in MsWord:
Developer --> Rich Text Coontro Context --> Write some text --> Developer --> Restrict Editing --> Editing restrictions --> Mark combobox ( Allow only…) and choose No Changes/ Filling in form --> Start Enforcment --> yes, Start enforcing protection --> Ok (without password)

@aolo23

We have not found this issue while using the latest version of Aspose.Words for Java 20.9. Please check the attached output document. output.zip (7.7 KB)

Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.

I’m upgrade version to 20.9 and I ave still the same not wanted result.
Current state: (screen from your solution)
aspose_res.png (1.7 KB)
Expected:
expected.png (2.7 KB)

@aolo23

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

We apologize for your inconvenience.

1 Like

Does the use of the symbol: WORDSNET mean that the problem in the .NET implementation is analyzed / fixed first? (I am only interested in JAVA repair). Can you explain mi it?

@aolo23

The latest version of Aspose.Words for Java is completely auto-ported from .NET, i.e. we do not write code for Aspose.Words for Java; it is generated out automatically from C# code of Aspose.Words for .NET. In your case, the issue which was logged with WORDSNET prefix, would be auto resolved for Java variant of Aspose.Words. Your problem (WORDSNET-21115) will be fixed as soon as the linked issue is resolved.