Hi,
Problem: Hyperlink Position Data Needed for Rasterized Text Shapes
Background
We use Aspose.Slides to convert PowerPoint presentations into an HTML5 format for web playback. As part of this conversion, we rasterize shapes (including AutoShapes with text) into PNG images using GetImage() / SaveShapeThumbnail(). The rasterized images are then displayed in our HTML5 player.
When a shape contains hyperlinked text, we need to overlay invisible clickable regions on top of the rasterized image so that users can click on the correct part of the text to navigate to the intended URL. To do this, we need the bounding rectangle of each hyperlinked text portion within the shape, in coordinates relative to the shape itself.
The Problem
Currently, when a textbox (AutoShape) contains multiple hyperlinks across different text runs, we have no way to determine where each hyperlinked portion of text was rendered within the rasterized image. We only know:
-
The overall shape position and dimensions
-
Which text portions carry hyperlinks (via IPortion.PortionFormat.HyperlinkClick / HyperlinkMouseOver)
-
The hyperlink URLs and action types
We do not know:
-
The x, y position of each text portion within the rendered shape
-
The width and height of each text portion’s bounding box
Without this positional data, we cannot create accurate clickable regions. The result is that all hyperlinks in a multi-link textbox currently point to the same destination (we can only assign one clickable region to the entire shape image).
What We Need from the Aspose API
For a given IAutoShape (or any shape with an ITextFrame), after the shape’s layout has been computed, we need to obtain the bounding rectangle of individual text portions (IPortion) or at minimum individual paragraphs (IParagraph).
Specifically, for each IPortion that has a HyperlinkClick or HyperlinkMouseOver, we need:
| Data | Description |
|---|---|
| X | Left edge of the text portion, relative to the shape’s top-left corner |
| Y | Top edge of the text portion, relative to the shape’s top-left corner |
| Width | Rendered width of the text portion |
| Height | Rendered height of the text portion |
These coordinates should reflect the final rendered layout – accounting for:
-
Font metrics (size, family, bold/italic)
-
Text wrapping and line breaks
-
Paragraph alignment (left, center, right, justified)
-
Paragraph spacing and indentation
-
Text margins/insets within the shape
-
Any transforms applied to the text frame
Questions for Aspose
-
Does IParagraph.GetRect() return the bounding rectangle of a paragraph in shape-relative coordinates? If so, does it account for all layout factors (wrapping, alignment, spacing, margins)?
-
Is there a way to get the bounding rectangle of an individual IPortion (text run) within a paragraph? We see references to IPortion.GetCoordinates() in some documentation – does this give us what we need? What coordinate system does it use?
-
If portion-level coordinates are not available, is there a recommended approach to determine where a specific text run renders within a shape? For example:
-
Can we get the paragraph rectangle and then compute portion offsets using IPortion.GetRect() or similar?
-
Is there a way to query the text layout engine for glyph positions?
-
Coordinate scale factor: When we call shape.GetImage(ShapeRenderingOptions, scaleFactor), the rasterized image is scaled. Do the paragraph/portion coordinates correspond to the unscaled shape dimensions, or do they account for the render scale? We need to map coordinates to the pixel space of the exported image.
-
Multi-line portions: If a single text run wraps across multiple lines (e.g., a long hyperlinked text that breaks mid-word), does the API return multiple rectangles, or one bounding box encompassing all lines of that portion?
Example Scenario
A textbox contains:
TM255 Introduction to Computing (linked to URL-A)
blank line
T212 Electronics (linked to URL-B)
Introduction to Electronics (linked to URL-C)
blank line
T312 Advanced Electronics (linked to URL-D)
Electronic Applications (linked to URL-E)
After rasterization, we need to know that “TM255 Introduction to Computing” rendered at approximately (10, 5, 350, 22) within the shape image, “T212 Electronics” at (10, 48, 200, 22), and so on – so we can make each region independently clickable with its correct URL.
Current Aspose Version
We are using Aspose.Slides for .NET. Please advise which version (if any) supports the portion/paragraph coordinate APIs we need, or if this is a feature request.
Thanks
Internal ref: CONN-4169911