How to Align Text in a TextFrame to Vertical Top Using Aspose.Slides for Node.js?

Hi support,

I’m unable to align text at the top inside a textframe. Can you please assist how to implement that in Aspose.slides using nodejs
Current alignment:
image.png (4.6 KB)

Desired alignment
image.png (5.5 KB)

Is there a way to do that like this ?
image.png (4.3 KB)

How can we align to top ?

@karanmarsh,
Thank you for contacting support.

I am working on the question and will get back to you as soon as possible.

@karanmarsh,
We have opened the following new ticket(s) in our internal issue tracking system and will consider the question according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESNODEJS-44

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@karanmarsh,
Please use the following code snippet:

// Instantiate presentation
var pres = new aspose.slides.Presentation();

// Get first slide
var sld = pres.getSlides().get_Item(0);

// Add a Rectangle shape
var rect = sld.getShapes().addAutoShape(aspose.slides.ShapeType.Rectangle, 100, 100, 500, 150);

// Add TextFrame to the Rectangle
var tf = rect.addTextFrame("This is the text");

// Set TextAnchor to Top
tf.getTextFrameFormat().setAnchoringType(java.newByte(aspose.slides.TextAnchorType.Top));

// Save presentation
pres.save(dataDir + "TextAnchorType.pptx", aspose.slides.SaveFormat.Pptx);

It throws below error.
image.png (32.6 KB)

@karanmarsh,
Please take a look at the code lines 34 and 35 in your code example and code example we provided. You should use the getTextFrameFormat method like this:

const txtFrame = ashp.getTextFrame();
txtFrame.getTextFrameFormat().setAnchoringType(java.newByte(aspose.slides.TextAnchorType.Top));

Yes, tried this. Throws this error.
image.png (37.8 KB)

@karanmarsh,
In the setAnchoringType you should pass

java.newByte(aspose.slides.TextAnchorType.Top)

instead of

aspose.slides.TextAnchorType.Top
1 Like

Resolved. Thank you!

@karanmarsh,
Thank you for using Aspose.Slides.