Free Support Forum - aspose.com

How to get Alignment of text (Java)

Hi,

I want to read the alignment of text from Layout slide. I want to inform that I am able to read alignment as [Left, Right, Centre, Not define] but I want to read alignment like[Top, Bottom, Middle] of Image Placeholder.

Can you please help how can I read properties[Top, Bottom, Middle]?

Below is the presentation in which there is a Image placeholder named as cobrandLogo on Layout Slide which has text aligned to centre and bottom of placeholder. How can I get those alignment. Specially [Top, Middle, Bottom] and want to know do Aspose slide java have that feasibility?
poc.zip (10.0 KB)

Version used of Aspose slide java is 19.12

Code I am Using:

try {
			Presentation presentation = new Presentation("poc2403-4.pptx");
			
			// For Layout.
			ILayoutSlide iLayoutSlide = presentation.getLayoutSlides().get_Item(0);
			for (int i = 0; i < iLayoutSlide.getShapes().size(); i++)  {
				if(iLayoutSlide.getShapes().get_Item(i).getName().equals("cobrandLogo")) {

					IAutoShape ashp = (IAutoShape) iLayoutSlide.getShapes().get_Item(i);
					
					// Accessing the text frame
					ITextFrame txtFrame = ashp.getTextFrame();
					
					// Create the Paragraph object for text frame
					IParagraph para = txtFrame.getParagraphs().get_Item(0);
					
					IPortion portion = para.getPortions().get_Item(0);

					System.out.println("Effect format " + para.getParagraphFormat().getEffective().getAlignment());

				}
		}
			
        } catch (Exception e) {
            e.printStackTrace();
        }

Please Let me know.

Thanks.

@saquibs,

I have observed your requirements and like to share that you need to add following line in your code to get the font alignment which is top, bottom, center or automatic.

System.out.println("Font Alignment " + para.getParagraphFormat().getEffective().getFontAlignment());

However, for your presentation the API is returning Automatic as value rather than Bottom. For that, I have created an issue with ID SLIDESJAVA-38071 in our issue tracking system to further investigate and resolve it. This thread has been linked with the issue so that you may be notified once the issue will be fixed.