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

Free Support Forum - aspose.com

Property units in Aspose.Slides

Hi,

I’m trying to figure out what is the unit for setting properties in ParagraphEx objects.

For example, I’m trying to set the left and right margin properties. The API only refers that the setter methods take float values, so it leaves you guessing as to what exactly the value is.

Are these (and any other properties) set in points? Pixels? Centimeters?


Thanks,

Marco

Hi Marco,


I am afraid that there are no properties available in terms of setting points, pixels or centimeters. The only option that is available in setting the margin properties. Moreover, the float value actually correspond to PowerPoint as well where values for margin are also set in float values. I hope it clear the concept to you.

Many Thanks,

Hi Mudassir,

Unfortunately, this concept is not clear to me.

If I set a paragraph’s margin by typing:

paragraph.setMarginLeft(12f);

what does the 12 stand for? How does Aspose measure the 12 I am inserting? Is it in pixels, centimeters, apples? How can I know how large the margin will be when I insert a floating 12 (or any other floating point number) as an argument?

Hi Marco,


Let me try to elaborate further. The default slide size is 10’’ x 7.5’’ which is equal to 720 x 540 in dimensions for slides. This means that one inch is equal to 72. The margin size in PowerPoint for PPTX are set in inches. So, in order to set the margin of 12’’ inches in PowerPoint, the value of 72*12=864 is set in Aspose.Slides to achieve the desired result. So, if you mean value 12 in Aspose.Slides, it means 12/72 inches in PowerPoint. I hope this will explain the concept more clearly. Secondly, when you set the margin value, it actually starts from the position of the shape. Let say if a shape is at position 144 in width (2 inches) and 72 in width( 1 inch). Then you set the margin for text inside the shape to be 12 inches, it will use relative position of shape i.e. 2 inches in X direction + 12 inches margin. So over all effect would be 14 but it will be 12 relative to position of slide. I have shared the sample code snippet that will help you further in this regard. Please share, if I may help you further.

//Instantiate PresentationEx
PresentationEx pres = new PresentationEx();
//Get the first slide
SlideEx sld = pres.Slides[0];
//Add an AutoShape of Rectangle type
int idx = sld.Shapes.AddAutoShape(ShapeTypeEx.Rectangle, 0, 0, 1008, 150);
//864 is equal to 12 inches. slide size is 720 x540 = 10’ x 7.5’
// This makes 1 inch=72. So, 14 inches 14 * 72= 864
AutoShapeEx ashp = (AutoShapeEx)sld.Shapes[idx];
//Add TextFrame to the Rectangle
ashp.AddTextFrame(" ");
// ParagraphEx para = ashp.TextFrame.Paragraphs[0];
ParagraphEx para = new ParagraphEx();
//We will give margin of 10 inches; i.e 12’’ * 72=864
//So we will set the margin for exactly 12 will be set at 864

para.ParagraphFormat.MarginLeft = 864f;

para.Text = “Indent”;
ashp .TextFrame .Paragraphs.Clear();
ashp .TextFrame.Paragraphs.Add(para);
ashp.FillFormat.FillType = FillTypeEx.NoFill;

//Write the presentation to disk
pres.Write(@“C:\Users\Mudassir\Downloads\TextBox.pptx”);


Many Thanks,
1 Like