Manage Text Portions in Presentations with Python
Get Coordinates of Text Portions
The get_coordinates method has been added to the Portion class which allows retrieving the coordinates of text portions:
import aspose.slides as slides
with slides.Presentation("HelloWorld.pptx") as presentation:
shape = presentation.slides[0].shapes[0]
text_frame = shape.text_frame
for paragraph in text_frame.paragraphs:
for portion in paragraph.portions:
point = portion.get_coordinates()
print("Corrdinates X =" + str(point.x) + " Corrdinates Y =" + str(point.y))
FAQ
Can I apply a hyperlink to only part of the text within a single paragraph?
Yes, you can assign a hyperlink to an individual portion; only that fragment will be clickable, not the entire paragraph.
How does style inheritance work: what does a Portion override, and what is taken from Paragraph/TextFrame?
Portion-level properties have the highest precedence. If a property is not set on the Portion, the engine takes it from the Paragraph; if it is not set there either, from the TextFrame or the theme style.
What happens if the font specified for a Portion is missing on the target machine/server?
Font substitution rules apply. The text may reflow: metrics, hyphenation, and width can change, which matters for precise positioning.
Can I set a Portion-specific text fill transparency or gradient independent of the rest of the paragraph?
Yes, text color, fill, and transparency at the Portion level can differ from neighboring fragments.