Set margin for text frame is not working

Hi Support,


I am trying to set the margin left and right of a paragraph, but the code that I am trying is not taking effect. The default margin for a shape remains 0.25.

This is the piece of code I am running:

IAutoShape box = group.getShapes().addAutoShape(
ShapeType.Rectangle,
rctShape.getA().getX().floatValue(),
rctShape.getA().getY().floatValue(),
rctShape.getB().getX().floatValue() - rctShape.getA().getX().floatValue(),
rctShape.getB().getY().floatValue() - rctShape.getA().getY().floatValue());
box.getFillFormat().setFillType(FillType.Solid);
box.getFillFormat().getSolidFillColor().setColor(Color.WHITE);
box.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.black);
box.getLineFormat().getFillFormat().setFillType(FillType.Solid);
box.getLineFormat().setWidth(1);

box.addTextFrame(" ");
ITextFrame txtFrame = box.getTextFrame();
IParagraph iParagraph = txtFrame.getParagraphs().get_Item(0);
IPortion portion = iParagraph.getPortions().get_Item(0);
portion.getPortionFormat().getFillFormat().setFillType(FillType.Solid);
portion.getPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.black);
portion.getPortionFormat().setFontHeight(10);
portion.getPortionFormat().setFontBold(NullableBool.True);
iParagraph.getParagraphFormat().setMarginLeft(0.01f); // also tried another values…
iParagraph.getParagraphFormat().setMarginRight(0.01f);
portion.setText(“My Text”);

Thank you.
Hi Guilherme,

I have worked with your source code shared by you using Aspose.Slides for JAVA 16.10.0 and unable to observe the issue. I have shared generated output for your kind reference. Please share feedback with us if there is still an issue. Please see attachments. Also shared code for your reference.

Best Regards,

Hi Adnan.Ahmad

Thanks for sharing your results.

I am running this piece of code. Please find attached TestMargin.txt
I edited the results manually just to show you what I want.

Thank you
Guiherme

Hi Guilherme,


I have worked with your source code and unable to observe the issue. I have shared screen shot for your kind reference. Please see attachments. I have share piece of code for your reference.

Best Regards,

Excellent!


I was setting the margin of the paragraph instead of setting it from the text frame
Here is the answer:
  ITextFrame txtFrame = box.getTextFrame();
IParagraph iParagraph = txtFrame.getParagraphs().get_Item(0);
IPortion portion = iParagraph.getPortions().get_Item(0);

txtFrame.getTextFrameFormat().setMarginBottom(13f);
txtFrame.getTextFrameFormat().setMarginTop(13f);
txtFrame.getTextFrameFormat().setMarginRight(0.0f);
txtFrame.getTextFrameFormat().setMarginLeft(0.0f);

Now I got the proper configuration!
Thank you very much Adnan.



Hi Guilherme,


You are very welcome.

Best Regards,